Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

partial remove onlyAllow from baked code, only keep in delete to be r…

…fc compliant
  • Loading branch information...
commit abe74adf8acbe9096c8f5e0339840ee68d2b0e81 1 parent 27d83ee
@ceeram ceeram authored
View
12 lib/Cake/Console/Templates/default/actions/controller_actions.ctp
@@ -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
7 lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php
@@ -353,8 +353,7 @@ public function testBakeActionsUsingSessions() {
$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 @@ public function testBakeActionsWithNoSessions() {
$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 @@ public function testBakeActionsWithNoSessions() {
$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);
}
Please sign in to comment.
Something went wrong with that request. Please try again.