Skip to content

Commit

Permalink
Change position of "$data" in Controller
Browse files Browse the repository at this point in the history
  • Loading branch information
rougin committed Oct 13, 2024
1 parent ea08f83 commit d0de623
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/Template/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ protected function setCreateMethod($name, $model, $type)
$lines[] = '/** @var array<string, mixed> */';
$lines[] = '$input = $this->input->post(null, true);';
$lines[] = '';
$lines[] = '$data = array();';
$lines[] = '';
$lines[] = 'if (! $input)';
$lines[] = '{';

Expand All @@ -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)
{
Expand All @@ -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[] = '{';
Expand Down
6 changes: 3 additions & 3 deletions tests/Fixture/Plates/Doctrine/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ public function create()
/** @var array<string, mixed> */
$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;
Expand All @@ -77,8 +79,6 @@ public function create()
// Specify logic here if applicable ---
$exists = $this->repo->exists($input);

$data = array();

if ($exists)
{
$data['error'] = '';
Expand Down
6 changes: 3 additions & 3 deletions tests/Fixture/Plates/Wildfire/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ public function create()
/** @var array<string, mixed> */
$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;
Expand All @@ -59,8 +61,6 @@ public function create()
// Specify logic here if applicable ---
$exists = $this->user->exists($input);

$data = array();

if ($exists)
{
$data['error'] = '';
Expand Down

0 comments on commit d0de623

Please sign in to comment.