partial remove onlyAllow from baked code, only keep in delete to be rfc compliant

This commit is contained in:
Ceeram 2012-08-25 14:43:12 +02:00
parent 27d83eedfe
commit abe74adf8a
2 changed files with 7 additions and 12 deletions

View file

@ -47,12 +47,10 @@
/**
* <?php echo $admin ?>add method
*
* @throws MethodNotAllowedException
* @return void
*/
public function <?php echo $admin ?>add() {
if ($this->request->data) {
$this->request->onlyAllow('post');
if ($this->request->is('post')) {
$this-><?php echo $currentModelName; ?>->create();
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
<?php if ($wannaUseSession): ?>
@ -88,7 +86,6 @@
/**
* <?php echo $admin ?>edit method
*
* @throws MethodNotAllowedException
* @throws NotFoundException
* @param string $id
* @return void
@ -98,8 +95,7 @@
if (!$this-><?php echo $currentModelName; ?>->exists()) {
throw new NotFoundException(__('Invalid <?php echo strtolower($singularHumanName); ?>'));
}
if ($this->request->data) {
$this->request->onlyAllow('post', 'put');
if ($this->request->is('post') || $this->request->is('put')) {
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
@ -135,17 +131,17 @@
/**
* <?php echo $admin ?>delete method
*
* @throws MethodNotAllowedException
* @throws NotFoundException
* @throws MethodNotAllowedException
* @param string $id
* @return void
*/
public function <?php echo $admin; ?>delete($id = null) {
$this->request->onlyAllow('post', 'delete');
$this-><?php echo $currentModelName; ?>->id = $id;
if (!$this-><?php echo $currentModelName; ?>->exists()) {
throw new NotFoundException(__('Invalid <?php echo strtolower($singularHumanName); ?>'));
}
$this->request->onlyAllow('post', 'delete');
if ($this-><?php echo $currentModelName; ?>->delete()) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'));

View file

@ -353,8 +353,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertContains("\$this->set('bakeArticle', \$this->BakeArticle->read(null, \$id)", $result);
$this->assertContains('function add()', $result);
$this->assertContains("if (\$this->request->data)", $result);
$this->assertContains("\$this->request->onlyAllow('post')", $result);
$this->assertContains("if (\$this->request->is('post'))", $result);
$this->assertContains('if ($this->BakeArticle->save($this->request->data))', $result);
$this->assertContains("\$this->Session->setFlash(__('The bake article has been saved'));", $result);
@ -393,8 +392,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertContains("\$this->set('bakeArticle', \$this->BakeArticle->read(null, \$id)", $result);
$this->assertContains('function add()', $result);
$this->assertContains("if (\$this->request->data)", $result);
$this->assertContains("\$this->request->onlyAllow('post')", $result);
$this->assertContains("if (\$this->request->is('post'))", $result);
$this->assertContains('if ($this->BakeArticle->save($this->request->data))', $result);
$this->assertContains("\$this->flash(__('The bake article has been saved.'), array('action' => 'index'))", $result);
@ -404,6 +402,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertContains("\$this->set(compact('bakeTags'))", $result);
$this->assertContains('function delete($id = null)', $result);
$this->assertContains("\$this->request->onlyAllow('post', 'delete')", $result);
$this->assertContains('if ($this->BakeArticle->delete())', $result);
$this->assertContains("\$this->flash(__('Bake article deleted'), array('action' => 'index'))", $result);
}