Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
much less unwhieldy like that
- Loading branch information
Showing
7 changed files
with
210 additions
and
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<% | ||
/** | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @since 3.0.0 | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
%> | ||
|
||
<% $compact = ["'" . $singularName . "'"]; %> | ||
/** | ||
* Add method | ||
* | ||
* @return void | ||
*/ | ||
public function add() { | ||
$<%= $singularName %> = $this-><%= $currentModelName %>->newEntity($this->request->data); | ||
if ($this->request->is('post')) { | ||
if ($this-><%= $currentModelName; %>->save($<%= $singularName %>)) { | ||
$this->Flash->success('The <%= strtolower($singularHumanName) %> has been saved.'); | ||
return $this->redirect(['action' => 'index']); | ||
} else { | ||
$this->Flash->error('The <%= strtolower($singularHumanName) %> could not be saved. Please, try again.'); | ||
} | ||
} | ||
<% | ||
foreach ($editAssociations as $assoc): | ||
$association = $modelObj->association($assoc); | ||
$otherName = $association->target()->alias(); | ||
$otherPlural = $this->_variableName($otherName); | ||
%> | ||
$<%= $otherPlural %> = $this-><%= $currentModelName %>-><%= $otherName %>->find('list'); | ||
<% | ||
$compact[] = "'<%= $otherPlural %>'"; | ||
endforeach; | ||
%> | ||
$this->set(compact(" <%= join(', ', $compact) %> ")); | ||
} |
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,33 @@ | ||
<% | ||
/** | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @since 3.0.0 | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
%> | ||
|
||
/** | ||
* Delete method | ||
* | ||
* @param string $id | ||
* @return void | ||
* @throws \Cake\Network\Exception\NotFoundException | ||
*/ | ||
public function delete($id = null) { | ||
$<%= $singularName %> = $this-><%= $currentModelName %>->get($id); | ||
$this->request->allowMethod(['post', 'delete']); | ||
if ($this-><%= $currentModelName; %>->delete($<%= $singularName %>)) { | ||
$this->Flash->success('The <%= strtolower($singularHumanName) %> has been deleted.'); | ||
} else { | ||
$this->Flash->error('The <%= strtolower($singularHumanName) %> 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<% | ||
/** | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @since 3.0.0 | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
%> | ||
|
||
<% $compact = ["'" . $singularName . "'"]; %> | ||
/** | ||
* Edit method | ||
* | ||
* @param string $id | ||
* @return void | ||
* @throws \Cake\Network\Exception\NotFoundException | ||
*/ | ||
public function edit($id = null) { | ||
$<%= $singularName %> = $this-><%= $currentModelName %>->get($id, [ | ||
'contain' => [<%= $this->Class->stringifyList($belongsToMany, ['indent' => 4]) %>] | ||
]); | ||
if ($this->request->is(['patch', 'post', 'put'])) { | ||
$<%= $singularName %> = $this-><%= $currentModelName %>->patchEntity($<%= $singularName %>, $this->request->data); | ||
if ($this-><%= $currentModelName; %>->save($<%= $singularName %>)) { | ||
$this->Flash->success('The <%= strtolower($singularHumanName) %> has been saved.'); | ||
return $this->redirect(['action' => 'index']); | ||
} else { | ||
$this->Flash->error('The <%= strtolower($singularHumanName) %> could not be saved. Please, try again.'); | ||
} | ||
} | ||
<% | ||
foreach ($editAssociations as $assoc): | ||
$association = $modelObj->association($assoc); | ||
$otherName = $association->target()->alias(); | ||
$otherPlural = $this->_variableName($otherName); | ||
%> | ||
$<%= $otherPlural %> = $this-><%= $currentModelName %>-><%= $otherName %>->find('list'); | ||
<% | ||
$compact[] = "'<%= $otherPlural %>'"; | ||
endforeach; | ||
%> | ||
$this->set(compact(" <%= join(', ', $compact) %> ")); | ||
} |
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,29 @@ | ||
<% | ||
/** | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @since 3.0.0 | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
%> | ||
|
||
/** | ||
* Index method | ||
* | ||
* @return void | ||
*/ | ||
public function index() { | ||
<% if ($belongsTo): %> | ||
$this->paginate = [ | ||
'contain' => [<%= $this->Class->stringifyList($belongsTo, ['indent' => 4]) %>] | ||
]; | ||
<% endif; %> | ||
$this->set('<%= $pluralName %>', $this->paginate($this-><%= $currentModelName %>)); | ||
} |
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,29 @@ | ||
<% | ||
/** | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @since 3.0.0 | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
%> | ||
|
||
/** | ||
* View method | ||
* | ||
* @param string $id | ||
* @return void | ||
* @throws \Cake\Network\Exception\NotFoundException | ||
*/ | ||
public function view($id = null) { | ||
$<%= $singularName%> = $this-><%= $currentModelName %>->get($id, [ | ||
'contain' => [<%= $this->Class->stringifyList($allAssociations, ['indent' => 4]) %>] | ||
]); | ||
$this->set('<%= $singularName %>', $<%= $singularName %>); | ||
} |
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