From d0de6238232cc558081c3146a0e8e71bf0d7dc00 Mon Sep 17 00:00:00 2001 From: Rougin Gutib Date: Sun, 13 Oct 2024 11:44:45 +0800 Subject: [PATCH] Change position of "$data" in Controller --- src/Template/Controller.php | 6 +++--- tests/Fixture/Plates/Doctrine/Controller.php | 6 +++--- tests/Fixture/Plates/Wildfire/Controller.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Template/Controller.php b/src/Template/Controller.php index 42f88d7..fe3d5d9 100644 --- a/src/Template/Controller.php +++ b/src/Template/Controller.php @@ -193,6 +193,8 @@ protected function setCreateMethod($name, $model, $type) $lines[] = '/** @var array */'; $lines[] = '$input = $this->input->post(null, true);'; $lines[] = ''; + $lines[] = '$data = array();'; + $lines[] = ''; $lines[] = 'if (! $input)'; $lines[] = '{'; @@ -202,7 +204,7 @@ protected function setCreateMethod($name, $model, $type) $lines[] = ' $this->load->view(\'layout/header\');'; } - $lines[] = ' $this->load->view(\'' . $name . '/create\');'; + $lines[] = ' $this->load->view(\'' . $name . '/create\', $data);'; if ($this->layout) { @@ -228,8 +230,6 @@ protected function setCreateMethod($name, $model, $type) $lines[] = '$exists = $this->repo->exists($input);'; } - $lines[] = ''; - $lines[] = '$data = array();'; $lines[] = ''; $lines[] = 'if ($exists)'; $lines[] = '{'; diff --git a/tests/Fixture/Plates/Doctrine/Controller.php b/tests/Fixture/Plates/Doctrine/Controller.php index 7d397d1..dc8291e 100644 --- a/tests/Fixture/Plates/Doctrine/Controller.php +++ b/tests/Fixture/Plates/Doctrine/Controller.php @@ -64,10 +64,12 @@ public function create() /** @var array */ $input = $this->input->post(null, true); + $data = array(); + if (! $input) { $this->load->view('layout/header'); - $this->load->view('users/create'); + $this->load->view('users/create', $data); $this->load->view('layout/footer'); return; @@ -77,8 +79,6 @@ public function create() // Specify logic here if applicable --- $exists = $this->repo->exists($input); - $data = array(); - if ($exists) { $data['error'] = ''; diff --git a/tests/Fixture/Plates/Wildfire/Controller.php b/tests/Fixture/Plates/Wildfire/Controller.php index f87799e..4ab251b 100644 --- a/tests/Fixture/Plates/Wildfire/Controller.php +++ b/tests/Fixture/Plates/Wildfire/Controller.php @@ -46,10 +46,12 @@ public function create() /** @var array */ $input = $this->input->post(null, true); + $data = array(); + if (! $input) { $this->load->view('layout/header'); - $this->load->view('users/create'); + $this->load->view('users/create', $data); $this->load->view('layout/footer'); return; @@ -59,8 +61,6 @@ public function create() // Specify logic here if applicable --- $exists = $this->user->exists($input); - $data = array(); - if ($exists) { $data['error'] = '';