2011-03-29 11 views
7

यह एक ज़ेंड फ्रेमवर्क प्रश्न है।इन जेडएफ कार्यक्रमों को किस क्रम में चलाया जाता है?

यदि मेरे पास नियंत्रक, एक एक्शन हेल्पर और प्लगइन है, तो उनकी घटनाओं का क्या क्रम होता है? नीचे मैंने उन घटनाओं को सूचीबद्ध किया है जिनमें मुझे रूचि है, जिस क्रम में मुझे लगता है कि वे होते हैं। क्या आदेश सही है?

  1. प्लगइन, routeStartup()
  2. प्लगइन, routeShutdown()
  3. प्लगइन, dispatchLoopStartup()
  4. प्लगइन, preDispatch()

  5. कार्रवाई हेल्पर, init()

  6. एक्शन हेल्पर, प्रीडिस्चैच()

  7. नियंत्रक, init()

  8. नियंत्रक, preDispatch()
  9. नियंत्रक, postDispatch()

  10. कार्रवाई हेल्पर, postDispatch()

  11. प्लगइन, postDispatch()

  12. प्लगइन, प्रेषण लूपशूटडाउन()

यह ओ मुझे यह बताता है कि, जब एक्शन हेल्पर और कंट्रोलर की बात आती है, तो init() विधियों की जोड़ी लगातार चल सकती है, इसके बाद प्रीडिस्चैच() विधियों की जोड़ी होती है, लेकिन मुझे नहीं लगता कि यह मामला है।

आपकी मदद के लिए धन्यवाद!

उत्तर

7

दिलचस्प प्रश्न। मुझे लगता है कि आप सही हैं, 7 और 6 को छोड़कर ओपोजिट होना चाहिए। इसे जांचने के लिए, मैंने एक जेडएफ एप्लीकेशन डीबग किया। यह मैंने पाया:

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 

उम्मीद है कि इससे मदद मिलती है।

+0

धन्यवाद मार्किन, यह शानदार है! –

2

http://www.zietlow.net/zend-framework/zend-framework-ablauf-des-dispatch-prozesses/44/

प्रेषण प्रक्रिया के बारे में अच्छा चित्रों के साथ 2 लिंक देखते हैं।

+0

हाय आर्नेरी, प्रतिक्रिया के लिए धन्यवाद। अनुक्रम आरेख बहुत अच्छा है, हालांकि इसमें केवल 12 कार्यक्रमों में से 8 शामिल हैं। –

संबंधित मुद्दे