Adding redirect() if deletion fails.

Fixing formatting.
This commit is contained in:
mark_story 2009-06-06 21:38:22 -04:00
parent 4d7f00504a
commit 5e5293a866
2 changed files with 19 additions and 13 deletions

View file

@ -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,7 +122,7 @@
$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)) {
@ -130,7 +130,13 @@
$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'));
}

View file

@ -318,13 +318,13 @@ class ControllerTaskTest extends CakeTestCase {
$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);
@ -332,7 +332,7 @@ class ControllerTaskTest extends CakeTestCase {
$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);
}
/**