Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modify controller task to render in one step
Instead of baking actions seperately, and passing actions as a string to the controller template - pass the array of action names directly to the controller template
- Loading branch information
Showing
12 changed files
with
276 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?php | ||
namespace App\Controller; | ||
|
||
use App\Controller\AppController; | ||
|
||
/** | ||
* BakeArticles Controller | ||
* | ||
* @property App\Model\Table\BakeArticlesTable $BakeArticles | ||
* @property CsrfComponent $Csrf | ||
* @property AuthComponent $Auth | ||
*/ | ||
class BakeArticlesController extends AppController { | ||
|
||
/** | ||
* Helpers | ||
* | ||
* @var array | ||
*/ | ||
public $helpers = ['Html', 'Time']; | ||
|
||
/** | ||
* Components | ||
* | ||
* @var array | ||
*/ | ||
public $components = ['Csrf', 'Auth']; | ||
|
||
/** | ||
* Index method | ||
* | ||
* @return void | ||
*/ | ||
public function index() { | ||
$this->paginate = [ | ||
'contain' => ['BakeUsers'] | ||
]; | ||
$this->set('bakeArticles', $this->paginate($this->BakeArticles)); | ||
} | ||
|
||
/** | ||
* View method | ||
* | ||
* @param string|null $id | ||
* @return void | ||
* @throws \Cake\Network\Exception\NotFoundException | ||
*/ | ||
public function view($id = null) { | ||
$bakeArticle = $this->BakeArticles->get($id, [ | ||
'contain' => ['BakeUsers', 'BakeTags', 'BakeComments'] | ||
]); | ||
$this->set('bakeArticle', $bakeArticle); | ||
} | ||
|
||
/** | ||
* Add method | ||
* | ||
* @return void | ||
*/ | ||
public function add() { | ||
$bakeArticle = $this->BakeArticles->newEntity($this->request->data); | ||
if ($this->request->is('post')) { | ||
if ($this->BakeArticles->save($bakeArticle)) { | ||
$this->Flash->success('The bake article has been saved.'); | ||
return $this->redirect(['action' => 'index']); | ||
} else { | ||
$this->Flash->error('The bake article could not be saved. Please, try again.'); | ||
} | ||
} | ||
$bakeUsers = $this->BakeArticles->BakeUsers->find('list'); | ||
$bakeTags = $this->BakeArticles->BakeTags->find('list'); | ||
$this->set(compact('bakeArticle', 'bakeUsers', 'bakeTags')); | ||
} | ||
|
||
/** | ||
* Edit method | ||
* | ||
* @param string|null $id | ||
* @return void | ||
* @throws \Cake\Network\Exception\NotFoundException | ||
*/ | ||
public function edit($id = null) { | ||
$bakeArticle = $this->BakeArticles->get($id, [ | ||
'contain' => ['BakeTags'] | ||
]); | ||
if ($this->request->is(['patch', 'post', 'put'])) { | ||
$bakeArticle = $this->BakeArticles->patchEntity($bakeArticle, $this->request->data); | ||
if ($this->BakeArticles->save($bakeArticle)) { | ||
$this->Flash->success('The bake article has been saved.'); | ||
return $this->redirect(['action' => 'index']); | ||
} else { | ||
$this->Flash->error('The bake article could not be saved. Please, try again.'); | ||
} | ||
} | ||
$bakeUsers = $this->BakeArticles->BakeUsers->find('list'); | ||
$bakeTags = $this->BakeArticles->BakeTags->find('list'); | ||
$this->set(compact('bakeArticle', 'bakeUsers', 'bakeTags')); | ||
} | ||
|
||
/** | ||
* Delete method | ||
* | ||
* @param string|null $id | ||
* @return void | ||
* @throws \Cake\Network\Exception\NotFoundException | ||
*/ | ||
public function delete($id = null) { | ||
$bakeArticle = $this->BakeArticles->get($id); | ||
$this->request->allowMethod(['post', 'delete']); | ||
if ($this->BakeArticles->delete($bakeArticle)) { | ||
$this->Flash->success('The bake article has been deleted.'); | ||
} else { | ||
$this->Flash->error('The bake article could not be deleted. Please, try again.'); | ||
} | ||
return $this->redirect(['action' => 'index']); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.