Example #1
0
 /**
  * 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();
         self::$_app = new Mage_Core_Model_App();
         self::$_events = new Varien_Event_Collection();
         self::$_config = new Mage_Core_Model_Config($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());
         }
     }
 }
Example #2
0
 /**
  * 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 {
         Magento_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));
         Magento_Profiler::stop('mage');
     } catch (Mage_Core_Model_Session_Exception $e) {
         header('Location: ' . self::getBaseUrl());
     } catch (Mage_Core_Model_Store_Exception $e) {
         require_once self::getBaseDir() . '/pub/errors/404.php';
     } catch (Exception $e) {
         self::printException($e);
     }
 }
Example #3
0
 /**
  * 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();
         self::$_app = new Mage_Core_Model_App();
         self::$_events = new Varien_Event_Collection();
         self::$_config = new Mage_Core_Model_Config();
         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) {
         $baseUrl = rtrim(self::getScriptSystemUrl('errors'), '/') . '/errors/404.php';
         if (!headers_sent()) {
             header('Location: ' . $baseUrl);
         } else {
             print '<script type="text/javascript">';
             print "window.location.href = '{$baseUrl}';";
             print '</script>';
         }
         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());
         }
     }
 }
 /**
  * Initialize and retrieve application
  *
  * @param   string $code
  * @param   string $type
  * @param   string|array $options
  * @return  Mage_Core_Model_App
  */
 public static function app($code = '', $type = 'store', $options = array())
 {
     if (null === self::$_app) {
         Varien_Profiler::start('mage::app::construct');
         self::$_app = new Mage_Core_Model_App();
         Varien_Profiler::stop('mage::app::construct');
         Mage::setRoot();
         Mage::register('events', new Varien_Event_Collection());
         Varien_Profiler::start('mage::app::register_config');
         Mage::register('config', new Mage_Core_Model_Config());
         Varien_Profiler::stop('mage::app::register_config');
         Varien_Profiler::start('mage::app::init');
         self::$_app->init($code, $type, $options);
         Varien_Profiler::stop('mage::app::init');
         self::$_app->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS);
     }
     return self::$_app;
 }
Example #5
0
 /**
  * Initialize and retrieve application
  *
  * @param   string $code
  * @param   string $type
  * @param   string $etcDir
  * @return  Mage_Core_Model_App
  */
 public static function app($code = '', $type = 'store', $etcDir = null)
 {
     if (is_null(self::$_app)) {
         Varien_Profiler::start('app/init');
         self::$_app = new Mage_Core_Model_App();
         Mage::setRoot();
         Mage::register('events', new Varien_Event_Collection());
         Mage::register('config', new Mage_Core_Model_Config());
         self::$_app->init($code, $type, $etcDir);
         self::$_app->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS);
     }
     return self::$_app;
 }