Hello,
 
I forgot to mention that, executing: 
"Zend_Controller_Request_Abstract::setDispatched(false);" does not solve the 
problem. Is there any way to execute an action after all the actions are 
already dispatched? postDispatch is executed for every action dispatch, right? 
How can one force the execution of one more action in the postDispatch OR 
dispatchLoopShutdown method?

Code that doesn't work:
 
public function postDispatch( Zend_Controller_Request_Abstract $request )
{
//var_dump( Zend_Controller_Front::getControllerDirectory() );

$stack = $this->getStack();
$leftMenuRequest = new Zend_Controller_Request_Simple();
$leftMenuRequest->setDispatched(false);
$leftMenuRequest->setModuleName('edms')
->setControllerName('menu')
->setActionName('index');
$stack->pushStack($leftMenuRequest);
Zend_Controller_Request_Abstract::setDispatched(false);
}
--- On Thu, 4/30/09, Andrei Iarus <[email protected]> wrote:

From: Andrei Iarus <[email protected]>
Subject: [fw-general] Menu in ZF: Controller Plugin with postDispatch method
To: "Zend Framework" <[email protected]>
Date: Thursday, April 30, 2009, 1:44 AM







Hello all,
 
I want to generate a menu for every page. As one of the quickest method (am I 
wrong here? are there quicker methods? at least it is quicker than calling 
action() from template) is to register a plugin that adds in the stack of the 
Zend_Front_Controller a new Zend_Controller_Request_Simple object. Because I 
need to colour some things in the menu (make active a link), I need this action 
executed after the dispatch process.
 
So I have this:
 
class Controller_Plugin_Menu extends Zend_Controller_Plugin_Abstract 
{ 
protected $_stack; 

public function postDispatch( Zend_Controller_Request_Abstract $request ) 
{ 
//var_dump( Zend_Controller_Front::getControllerDirectory() ); 
$stack = $this->getStack(); 
$leftMenuRequest = new Zend_Controller_Request_Simple(); 
$leftMenuRequest->setModuleName('edms') 
->setControllerName('menu') 
->setActionName('index'); 
$stack->pushStack($leftMenuRequest); 
} 

public function getStack() 
{ 
if (null === $this->_stack) { 
$front = Zend_Controller_Front::getInstance(); 
if (!$front->hasPlugin('Zend_Controller_Plugin_ActionStack')) { 
$stack = new Zend_Controller_Plugin_ActionStack(); 
$front->registerPlugin($stack); 
} else { 
$stack = $front->getPlugin('ActionStack'); 
} 
$this->_stack = $stack; 
} 
return $this->_stack; 
} 
}
 
The problem now is that this action is never executed . What is wrong? Do I 
have to set some flags in order to get that action executed? 
 
A second small question: How can get the list of all modules registered to the 
Front_Controller from within that plugin?
 
Thank you very much,
Andrei



      

Reply via email to