Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Controller/TagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TagsController extends TagsAppController
* @var array
*/
public $components = array(
'Session',
'Flash',
'Paginator'
);

Expand Down Expand Up @@ -70,7 +70,7 @@ public function view($id = null)
try {
$this->set('tag', $this->{$this->modelClass}->view($id));
} catch (Exception $e) {
$this->Session->setFlash($e->getMessage());
$this->Flash->warning($e->getMessage());
$this->redirect('/');
}
}
Expand All @@ -97,7 +97,7 @@ public function admin_view($id)
try {
$this->set('tag', $this->{$this->modelClass}->view($id));
} catch (Exception $e) {
$this->Session->setFlash($e->getMessage());
$this->Flash->warning($e->getMessage());
$this->redirect('/');
}
}
Expand All @@ -111,7 +111,7 @@ public function admin_add()
{
if (!empty($this->request->data)) {
if ($this->{$this->modelClass}->add($this->request->data)) {
$this->Session->setFlash(__d('tags', 'The Tags has been saved.'));
$this->Flash->success(__d('tags', 'The Tags has been saved.'));
$this->redirect(array('action' => 'index'));
}
}
Expand All @@ -128,13 +128,13 @@ public function admin_edit($id = null)
try {
$result = $this->{$this->modelClass}->edit($id, $this->request->data);
if ($result === true) {
$this->Session->setFlash(__d('tags', 'Tag saved.'));
$this->Flash->success(__d('tags', 'Tag saved.'));
$this->redirect(array('action' => 'index'));
} else {
$this->request->data = $result;
}
} catch (Exception $e) {
$this->Session->setFlash($e->getMessage());
$this->Flash->warning($e->getMessage());
$this->redirect(array('action' => 'index'));
}

Expand All @@ -152,9 +152,9 @@ public function admin_edit($id = null)
public function admin_delete($id = null)
{
if ($this->{$this->modelClass}->delete($id)) {
$this->Session->setFlash(__d('tags', 'Tag deleted.'));
$this->Flash->success(__d('tags', 'Tag deleted.'));
} else {
$this->Session->setFlash(__d('tags', 'Invalid Tag.'));
$this->Flash->warning(__d('tags', 'Invalid Tag.'));
}
$this->redirect(array('action' => 'index'));
}
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Controller/TagsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function setUp()
'named' => array(),
'url' => array());
$this->Tags->constructClasses();
$this->Tags->Session = $this->getMock('SessionComponent', array(), array(), '', false);
$this->Tags->Flash = $this->getMock('FlashComponent', array(), array(), '', false);
}

/**
Expand Down Expand Up @@ -180,13 +180,13 @@ public function testAdminIndex()
*/
public function testAdminDelete()
{
$this->Tags->Session->expects($this->at(0))
->method('setFlash')
$this->Tags->Flash->expects($this->at(0))
->method('warning')
->with($this->equalTo(__d('tags', 'Invalid Tag.')))
->will($this->returnValue(true));

$this->Tags->Session->expects($this->at(1))
->method('setFlash')
$this->Tags->Flash->expects($this->at(1))
->method('success')
->with($this->equalTo(__d('tags', 'Tag deleted.')))
->will($this->returnValue(true));

Expand Down