diff --git a/frameworks/PHP/cakephp/src/Controller/FortunesController.php b/frameworks/PHP/cakephp/src/Controller/FortunesController.php index bbec8ceb7f3..791b54c2932 100644 --- a/frameworks/PHP/cakephp/src/Controller/FortunesController.php +++ b/frameworks/PHP/cakephp/src/Controller/FortunesController.php @@ -2,14 +2,14 @@ namespace App\Controller; -use App\Model\Entity\Fortune; use Cake\ORM\TableRegistry; class FortunesController extends AppController { public function index() { - $this->viewBuilder()->setLayout('fortunes'); - $this->loadModel('Fortune'); + $viewBuilder = $this->viewBuilder(); + $viewBuilder->setLayout('fortunes'); + $viewBuilder->setTemplate('/Fortunes/index'); $fortunesTable = TableRegistry::getTableLocator()->get('Fortune'); @@ -21,15 +21,15 @@ public function index() { - // stuffing in the dynamic data - $fortune = TableRegistry::getTableLocator()->get('Fortune')->newEntity([ - 'id' => 0, - 'message' => 'Additional fortune added at request time.' - ]); + // stuffing in the dynamic data + $fortune = $fortunesTable->newEntity([ + 'id' => 0, + 'message' => 'Additional fortune added at request time.' + ]); - $fortunes = $fortunes->appendItem($fortune); + $fortunes = $fortunes->appendItem($fortune); - $fortunes = $fortunes->sortBy('message', SORT_ASC, SORT_STRING)->compile(false); + $fortunes = $fortunes->sortBy('message', SORT_ASC, SORT_STRING)->compile(false); $this->set('fortunes', $fortunes); }