diff --git a/templates/bake/element/Controller/add.twig b/templates/bake/element/Controller/add.twig index 72f26cb0..0e003205 100644 --- a/templates/bake/element/Controller/add.twig +++ b/templates/bake/element/Controller/add.twig @@ -37,7 +37,7 @@ {%- for assoc in associations %} {%- set otherName = Bake.getAssociatedTableAlias(modelObj, assoc) %} {%- set otherPlural = otherName|variable %} - ${{ otherPlural }} = $this->{{ currentModelName }}->{{ otherName }}->find('list', ['limit' => 200])->all(); + ${{ otherPlural }} = $this->{{ currentModelName }}->{{ otherName }}->find('list', limit: 200)->all(); {{- "\n" }} {%- set compact = compact|merge(["'#{otherPlural}'"]) %} {% endfor %} diff --git a/templates/bake/element/Controller/edit.twig b/templates/bake/element/Controller/edit.twig index 50d7531e..e6b2164d 100644 --- a/templates/bake/element/Controller/edit.twig +++ b/templates/bake/element/Controller/edit.twig @@ -25,9 +25,7 @@ */ public function edit($id = null) { - ${{ singularName }} = $this->{{ currentModelName }}->get($id, [ - 'contain' => {{ Bake.exportArray(belongsToMany)|raw }}, - ]); + ${{ singularName }} = $this->{{ currentModelName }}->get($id, contain: {{ Bake.exportArray(belongsToMany)|raw }}); if ($this->request->is(['patch', 'post', 'put'])) { ${{ singularName }} = $this->{{ currentModelName }}->patchEntity(${{ singularName }}, $this->request->getData()); if ($this->{{ currentModelName }}->save(${{ singularName }})) { @@ -40,7 +38,7 @@ {% for assoc in belongsTo|merge(belongsToMany) %} {%- set otherName = Bake.getAssociatedTableAlias(modelObj, assoc) %} {%- set otherPlural = otherName|variable %} - ${{ otherPlural }} = $this->{{ currentModelName }}->{{ otherName }}->find('list', ['limit' => 200])->all(); + ${{ otherPlural }} = $this->{{ currentModelName }}->{{ otherName }}->find('list', limit: 200)->all(); {{- "\n" }} {%- set compact = compact|merge(["'#{otherPlural}'"]) %} {% endfor %} diff --git a/templates/bake/element/Controller/view.twig b/templates/bake/element/Controller/view.twig index e2badd89..3d7cdf8d 100644 --- a/templates/bake/element/Controller/view.twig +++ b/templates/bake/element/Controller/view.twig @@ -26,9 +26,6 @@ */ public function view($id = null) { - ${{ singularName }} = $this->{{ currentModelName }}->get($id, [ - 'contain' => {{ Bake.exportArray(allAssociations)|raw }}, - ]); - + ${{ singularName }} = $this->{{ currentModelName }}->get($id, contain: {{ Bake.exportArray(allAssociations)|raw }}); $this->set(compact('{{ singularName }}')); } diff --git a/tests/comparisons/Controller/testBakeActions.php b/tests/comparisons/Controller/testBakeActions.php index 5cbc6e12..ff924991 100644 --- a/tests/comparisons/Controller/testBakeActions.php +++ b/tests/comparisons/Controller/testBakeActions.php @@ -49,10 +49,7 @@ public function index() */ public function view($id = null) { - $bakeArticle = $this->BakeArticles->get($id, [ - 'contain' => ['BakeUsers', 'BakeTags', 'BakeComments'], - ]); - + $bakeArticle = $this->BakeArticles->get($id, contain: ['BakeUsers', 'BakeTags', 'BakeComments']); $this->set(compact('bakeArticle')); } @@ -73,8 +70,8 @@ public function add() } $this->Flash->error(__('The bake article could not be saved. Please, try again.')); } - $bakeUsers = $this->BakeArticles->BakeUsers->find('list', ['limit' => 200])->all(); - $bakeTags = $this->BakeArticles->BakeTags->find('list', ['limit' => 200])->all(); + $bakeUsers = $this->BakeArticles->BakeUsers->find('list', limit: 200)->all(); + $bakeTags = $this->BakeArticles->BakeTags->find('list', limit: 200)->all(); $this->set(compact('bakeArticle', 'bakeUsers', 'bakeTags')); } @@ -87,9 +84,7 @@ public function add() */ public function edit($id = null) { - $bakeArticle = $this->BakeArticles->get($id, [ - 'contain' => ['BakeTags'], - ]); + $bakeArticle = $this->BakeArticles->get($id, contain: ['BakeTags']); if ($this->request->is(['patch', 'post', 'put'])) { $bakeArticle = $this->BakeArticles->patchEntity($bakeArticle, $this->request->getData()); if ($this->BakeArticles->save($bakeArticle)) { @@ -99,8 +94,8 @@ public function edit($id = null) } $this->Flash->error(__('The bake article could not be saved. Please, try again.')); } - $bakeUsers = $this->BakeArticles->BakeUsers->find('list', ['limit' => 200])->all(); - $bakeTags = $this->BakeArticles->BakeTags->find('list', ['limit' => 200])->all(); + $bakeUsers = $this->BakeArticles->BakeUsers->find('list', limit: 200)->all(); + $bakeTags = $this->BakeArticles->BakeTags->find('list', limit: 200)->all(); $this->set(compact('bakeArticle', 'bakeUsers', 'bakeTags')); } diff --git a/tests/comparisons/Controller/testBakeActionsContent.php b/tests/comparisons/Controller/testBakeActionsContent.php index fcdfcdd2..8f3df094 100644 --- a/tests/comparisons/Controller/testBakeActionsContent.php +++ b/tests/comparisons/Controller/testBakeActionsContent.php @@ -33,10 +33,7 @@ public function index() */ public function view($id = null) { - $bakeArticle = $this->BakeArticles->get($id, [ - 'contain' => ['BakeUsers', 'BakeTags', 'BakeComments'], - ]); - + $bakeArticle = $this->BakeArticles->get($id, contain: ['BakeUsers', 'BakeTags', 'BakeComments']); $this->set(compact('bakeArticle')); } @@ -57,8 +54,8 @@ public function add() } $this->Flash->error(__('The bake article could not be saved. Please, try again.')); } - $bakeUsers = $this->BakeArticles->BakeUsers->find('list', ['limit' => 200])->all(); - $bakeTags = $this->BakeArticles->BakeTags->find('list', ['limit' => 200])->all(); + $bakeUsers = $this->BakeArticles->BakeUsers->find('list', limit: 200)->all(); + $bakeTags = $this->BakeArticles->BakeTags->find('list', limit: 200)->all(); $this->set(compact('bakeArticle', 'bakeUsers', 'bakeTags')); } @@ -71,9 +68,7 @@ public function add() */ public function edit($id = null) { - $bakeArticle = $this->BakeArticles->get($id, [ - 'contain' => ['BakeTags'], - ]); + $bakeArticle = $this->BakeArticles->get($id, contain: ['BakeTags']); if ($this->request->is(['patch', 'post', 'put'])) { $bakeArticle = $this->BakeArticles->patchEntity($bakeArticle, $this->request->getData()); if ($this->BakeArticles->save($bakeArticle)) { @@ -83,8 +78,8 @@ public function edit($id = null) } $this->Flash->error(__('The bake article could not be saved. Please, try again.')); } - $bakeUsers = $this->BakeArticles->BakeUsers->find('list', ['limit' => 200])->all(); - $bakeTags = $this->BakeArticles->BakeTags->find('list', ['limit' => 200])->all(); + $bakeUsers = $this->BakeArticles->BakeUsers->find('list', limit: 200)->all(); + $bakeTags = $this->BakeArticles->BakeTags->find('list', limit: 200)->all(); $this->set(compact('bakeArticle', 'bakeUsers', 'bakeTags')); } diff --git a/tests/comparisons/Controller/testBakeWithPlugin.php b/tests/comparisons/Controller/testBakeWithPlugin.php index d28dae4b..fb16c6e7 100644 --- a/tests/comparisons/Controller/testBakeWithPlugin.php +++ b/tests/comparisons/Controller/testBakeWithPlugin.php @@ -35,10 +35,7 @@ public function index() */ public function view($id = null) { - $bakeArticle = $this->BakeArticles->get($id, [ - 'contain' => ['BakeUsers', 'BakeTags', 'BakeComments'], - ]); - + $bakeArticle = $this->BakeArticles->get($id, contain: ['BakeUsers', 'BakeTags', 'BakeComments']); $this->set(compact('bakeArticle')); } @@ -59,8 +56,8 @@ public function add() } $this->Flash->error(__('The bake article could not be saved. Please, try again.')); } - $bakeUsers = $this->BakeArticles->BakeUsers->find('list', ['limit' => 200])->all(); - $bakeTags = $this->BakeArticles->BakeTags->find('list', ['limit' => 200])->all(); + $bakeUsers = $this->BakeArticles->BakeUsers->find('list', limit: 200)->all(); + $bakeTags = $this->BakeArticles->BakeTags->find('list', limit: 200)->all(); $this->set(compact('bakeArticle', 'bakeUsers', 'bakeTags')); } @@ -73,9 +70,7 @@ public function add() */ public function edit($id = null) { - $bakeArticle = $this->BakeArticles->get($id, [ - 'contain' => ['BakeTags'], - ]); + $bakeArticle = $this->BakeArticles->get($id, contain: ['BakeTags']); if ($this->request->is(['patch', 'post', 'put'])) { $bakeArticle = $this->BakeArticles->patchEntity($bakeArticle, $this->request->getData()); if ($this->BakeArticles->save($bakeArticle)) { @@ -85,8 +80,8 @@ public function edit($id = null) } $this->Flash->error(__('The bake article could not be saved. Please, try again.')); } - $bakeUsers = $this->BakeArticles->BakeUsers->find('list', ['limit' => 200])->all(); - $bakeTags = $this->BakeArticles->BakeTags->find('list', ['limit' => 200])->all(); + $bakeUsers = $this->BakeArticles->BakeUsers->find('list', limit: 200)->all(); + $bakeTags = $this->BakeArticles->BakeTags->find('list', limit: 200)->all(); $this->set(compact('bakeArticle', 'bakeUsers', 'bakeTags')); }