Reputation: 9076
Here is some code from my controller:
if($user->save()) {
$this->_flash->setNamespace('success')->addMessage('Record deleted');
$this->_logger->info('About to log out');
$this->_forward('logout');
$this->_logger->info('Should Not Get To this line');
} else {
For some reason, the _forward() action is not executing. The phrase 'Should Not Get To this line' is showing up in my log files, and if I put some logging code in the logout() method, it never gets called. Bizarre.
I am using an ACL to secure the controller, but it doesn't do anything unusual. Obviously my user has appropriate authorisation otherwise they would get to this point in the code in the first place.
I am not doing anything unusual in my Bootstrap...
Any ideas??? Thanks...
Upvotes: 0
Views: 192
Reputation: 8186
You need to return after forward
if($user->save()) {
$this->_flash->setNamespace('success')->addMessage('Record deleted');
$this->_logger->info('About to log out');
$this->_forward('logout');
return;
$this->_logger->info('Should Not Get To this line');
} else {
Upvotes: 0
Reputation: 164809
From the manual
after the current action is processed, the action requested in _forward() will be executed
Calling _forward()
does not immediately halt execution of the current action.
To me, it looks like you're actually after a redirect. Try replacing your _forward()
line with
return $this->_helper->redirector('logout');
Upvotes: 3