开发者

Zend Action Controller is ignoring my _forward()

开发者 https://www.devze.com 2023-03-28 06:38 出处:网络
Here is some code from my controller: if($user->save()) { $this->_flash->setNamespace(\'success\')->addMessage(\'Record deleted\');

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...


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');


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 {
0

精彩评论

暂无评论...
验证码 换一张
取 消