Permalink
Browse files

Adding redirect() if deletion fails.

Fixing formatting.
  • Loading branch information...
1 parent 4d7f005 commit 5e5293a8666a86c5e11d3af545859503b6f78411 @markstory markstory committed Jun 7, 2009
@@ -30,9 +30,9 @@
if (!$id) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('Invalid <?php echo $singularHumanName ?>', true));
- $this->redirect(array('action'=>'index'));
+ $this->redirect(array('action' => 'index'));
<?php else: ?>
- $this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action'=>'index'));
+ $this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action' => 'index'));
<?php endif; ?>
}
$this->set('<?php echo $singularName; ?>', $this-><?php echo $currentModelName; ?>->read(null, $id));
@@ -45,9 +45,9 @@
if ($this-><?php echo $currentModelName; ?>->save($this->data)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> has been saved', true));
- $this->redirect(array('action'=>'index'));
+ $this->redirect(array('action' => 'index'));
<?php else: ?>
- $this->flash(__('<?php echo $currentModelName; ?> saved.', true), array('action'=>'index'));
+ $this->flash(__('<?php echo $currentModelName; ?> saved.', true), array('action' => 'index'));
<?php endif; ?>
} else {
<?php if ($wannaUseSession): ?>
@@ -77,18 +77,18 @@
if (!$id && empty($this->data)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('Invalid <?php echo $singularHumanName; ?>', true));
- $this->redirect(array('action'=>'index'));
+ $this->redirect(array('action' => 'index'));
<?php else: ?>
- $this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action'=>'index'));
+ $this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action' => 'index'));
<?php endif; ?>
}
if (!empty($this->data)) {
if ($this-><?php echo $currentModelName; ?>->save($this->data)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> has been saved', true));
- $this->redirect(array('action'=>'index'));
+ $this->redirect(array('action' => 'index'));
<?php else: ?>
- $this->flash(__('The <?php echo $singularHumanName; ?> has been saved.', true), array('action'=>'index'));
+ $this->flash(__('The <?php echo $singularHumanName; ?> has been saved.', true), array('action' => 'index'));
<?php endif; ?>
} else {
<?php if ($wannaUseSession): ?>
@@ -122,15 +122,21 @@
$this->Session->setFlash(__('Invalid id for <?php echo $singularHumanName; ?>', true));
$this->redirect(array('action'=>'index'));
<?php else: ?>
- $this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action'=>'index'));
+ $this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action' => 'index'));
<?php endif; ?>
}
if ($this-><?php echo $currentModelName; ?>->del($id)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('<?php echo $singularHumanName; ?> deleted', true));
$this->redirect(array('action'=>'index'));
<?php else: ?>
- $this->flash(__('<?php echo $singularHumanName; ?> deleted', true), array('action'=>'index'));
+ $this->flash(__('<?php echo $singularHumanName; ?> deleted', true), array('action' => 'index'));
<?php endif; ?>
}
+<?php if ($wannaUseSession): ?>
+ $this->Session->setFlash(__('<?php echo $singularHumanName; ?> was not deleted', true));
+<?php else: ?>
+ $this->flash(__('<?php echo $singularHumanName; ?> was not deleted', true), array('action' => 'index'));
+<?php endif; ?>
+ $this->redirect(array('action' => 'index'));
}
@@ -318,21 +318,21 @@ function testBakeActionsWithNoSessions() {
$this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false);
$this->assertTrue(strpos($result, 'function view($id = null)') !== false);
- $this->assertTrue(strpos($result, "\$this->flash(__('Invalid Article', true), array('action'=>'index'))") !== false);
+ $this->assertTrue(strpos($result, "\$this->flash(__('Invalid Article', true), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, "\$this->set('article', \$this->Article->read(null, \$id)") !== false);
$this->assertTrue(strpos($result, 'function add()') !== false);
$this->assertTrue(strpos($result, 'if (!empty($this->data))') !== false);
$this->assertTrue(strpos($result, 'if ($this->Article->save($this->data))') !== false);
- $this->assertTrue(strpos($result, "\$this->flash(__('The Article has been saved.', true), array('action'=>'index'))") !== false);
+ $this->assertTrue(strpos($result, "\$this->flash(__('The Article has been saved.', true), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, 'function edit($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->Article->Tag->find('list')") !== false);
$this->assertTrue(strpos($result, "\$this->set(compact('tags'))") !== false);
$this->assertTrue(strpos($result, 'function delete($id = null)') !== false);
$this->assertTrue(strpos($result, 'if ($this->Article->del($id))') !== false);
- $this->assertTrue(strpos($result, "\$this->flash(__('Article deleted', true), array('action'=>'index'))") !== false);
+ $this->assertTrue(strpos($result, "\$this->flash(__('Article deleted', true), array('action' => 'index'))") !== false);
}
/**

0 comments on commit 5e5293a

Please sign in to comment.