2011-03-29 9 views
7

Esta es una pregunta de Zend Framework.¿En qué orden se ejecutan estos eventos ZF?

Si tengo un Controlador, un Ayudante de acción y un Complemento, ¿en qué orden ocurren sus eventos? A continuación, he enumerado los eventos en los que estoy interesado, en el orden en que CREO que ocurren. Es el orden correcto?

  1. Plugin, routeStartup()
  2. Plugin, routeShutdown()
  3. Plugin, dispatchLoopStartup()
  4. Plugin, preDispatch()

  5. ayudante de acciones, init()

  6. Action Helper, preDispatch()

  7. Controller, init()

  8. Controller, preDispatch()
  9. Controller, postDispatch()

  10. ayudante de acciones, postDispatch()

  11. Plugin, postDispatch()

  12. Complemento, dispatchLoopShutdown()

Es o Me di cuenta de que, cuando se trata de Action Helper y Controller, el par de métodos init() puede ejecutarse consecutivamente, seguido por el par de métodos preDispatch(), pero no creo que este sea el caso.

Gracias por su ayuda!

Respuesta

7

Preguntas interesantes. Creo que tienes razón, excepto que 7 y 6 deben ser opuestos. Para verificarlo, depuré una aplicación ZF. Esto es lo que encontré:

1. $this->_plugins->routeStartup($this->_request);   #$this is Zend_Controller_Front 

    $router->route($this->_request);      #$router is Zend_Controller_Router_Rewrite, and method route finds a matching route to the current PATH_INFO 

2. $this->_plugins->routeShutdown($this->_request);  #$this is Zend_Controller_Front 

3. $this->_plugins->dispatchLoopStartup($this->_request); #$this is Zend_Controller_Front 

4. $this->_plugins->preDispatch($this->_request);   #$this is Zend_Controller_Front 

5. $helper->init(); # exectued for helpers by Zend_Controller_Action_HelperBroker 
         # during making an instance of IndexController. 
         # Specifically for Zend_Controller_Action_Helper_ViewRenderer 
         # and Zend_Layout_Controller_Action_Helper_Layout 


// IndexControlles has just been instantiated 


6. $this->init();      # $this is IndexController 

7. $this->_helper->notifyPreDispatch(); # $this is IndexController 

8. $this->preDispatch();     # $this is IndexController 

    $this->$action();      # $this is IndexController (action executed) 

9. $this->postDispatch();    # $this is IndexController 

10. $this->_helper->notifyPostDispatch(); # $this is IndexController 


// Execution of IndexController has just finished 


11. $this->_plugins->postDispatch($this->_request); #$this is Zend_Controller_Front 

12. $this->_plugins->dispatchLoopShutdown();   #$this is Zend_Controller_Front 


// after that response is sent 

$this->_response->sendResponse();     #$this is Zend_Controller_Front 

Hope this helps.

+0

Gracias Marcin, ¡esto es fantástico! –

Cuestiones relacionadas