Certificated magento

2.15) Describe how and when Magento flushes output variables using the front controller

In the function dispatch() of Front_Controller, we will see the code below:

Mage_Core_Controller_Varien_Front->dispatch()

    public function dispatch()

    {

        $request = $this->getRequest();

 

        // If pre-configured, check equality of base URL and requested URL

        $this->_checkBaseUrl($request);

 

        $request->setPathInfo()->setDispatched(false);

 

        $this->_getRequestRewriteController()->rewrite();

 

        Varien_Profiler::start('mage::dispatch::routers_match');

        $i = 0;

        while (!$request->isDispatched() && $i++ < 100) {

            foreach ($this->_routers as $router) {

                /** @var $router Mage_Core_Controller_Varien_Router_Abstract */

                if ($router->match($request)) {

                    break;

                }

            }

        }

        Varien_Profiler::stop('mage::dispatch::routers_match');

        if ($i>100) {

            Mage::throwException('Front controller reached 100 router match iterations');

        }

        // This event gives possibility to launch something before sending output (allow cookie setting)

        Mage::dispatchEvent('controller_front_send_response_before', array('front'=>$this));

        Varien_Profiler::start('mage::app::dispatch::send_response');

        $this->getResponse()->sendResponse();

        Varien_Profiler::stop('mage::app::dispatch::send_response');

        Mage::dispatchEvent('controller_front_send_response_after', array('front'=>$this));

        return $this;

    }

Varien_Profiler::start('mage::app::dispatch::send_response');
$this->getResponse()->sendResponse();
Varien_Profiler::stop('mage::app::dispatch::send_response');
This function will be called after the system selects controller and runs action corresponding to the request. Command line $this->getResponse()->sendResponse(); will flush output variables to html for browser.
 

0 Bình luận

Trở về
  • 1.12) Set up a cron job
  • 1.12) Set up a cron job

    Let’s start with server setup.   As any complex system, Magento has a lot of tasks that need to be executed...