Certificated magento

Q.2.6) When are the request and response objects initialized?

 The request and response objects are initialized early in the bootstrap, in the Mage_Core_Model_App->run() method.

 
index.php calls Mage::run()
Mage::run() (/app/Mage.php) calls Mage_Core_Model_App->run()
Mage_Core_Model_App->run() initializes the request and response objects.
 
Mage::run()
    /**
   * Front end main entry point
   *
   * @param string $code
   * @param string $type
   * @param string|array $options
   */
  public static function run($code = '', $type = 'store', $options = array())
  {
      try {
          Varien_Profiler::start('mage');
          self::setRoot();
          if (isset($options['edition'])) {
              self::$_currentEdition = $options['edition'];
          }
          self::$_app    = new Mage_Core_Model_App();
          if (isset($options['request'])) {
               self::$_app->setRequest($options['request']);
           }
          if (isset($options['response'])) {
               self::$_app->setResponse($options['response']);
           }
          self::$_events = new Varien_Event_Collection();
          self::_setIsInstalled($options);
          self::_setConfigModel($options);
          self::$_app->run(array(
              'scope_code' => $code,
              'scope_type' => $type,
              'options'    => $options,
          ));
          Varien_Profiler::stop('mage');
      } catch (Mage_Core_Model_Session_Exception $e) {
          header('Location: ' . self::getBaseUrl());
          die();
      } catch (Mage_Core_Model_Store_Exception $e) {
          require_once(self::getBaseDir() . DS . 'errors' . DS . '404.php');
          die();
      } catch (Exception $e) {
          if (self::isInstalled() || self::$_isDownloader) {
              self::printException($e);
              exit();
          }
          try {
              self::dispatchEvent('mage_run_exception', array('exception' => $e));
              if (!headers_sent()) {
                  header('Location:' . self::getUrl('install'));
              } else {
                  self::printException($e);
              }
          } catch (Exception $ne) {
              self::printException($ne, $e->getMessage());
          }
      }
  }
 

Mage_Core_Model_App->run()

 public function run($params)
    {
        $options = isset($params['options']) ? $params['options'] : array();
        $this->baseInit($options);
        Mage::register('application_params', $params);

        if ($this->_cache->processRequest()) {
            $this->getResponse()->sendResponse();
        } else {
            $this->_initModules();
            $this->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS);

            if ($this->_config->isLocalConfigLoaded()) {
                $scopeCode = isset($params['scope_code']) ? $params['scope_code'] : '';
                $scopeType = isset($params['scope_type']) ? $params['scope_type'] : 'store';
                $this->_initCurrentStore($scopeCode, $scopeType);
                $this->_initRequest();
                Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
            }

            $this->getFrontController()->dispatch();
        }
        return $this;
    }

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