/** * Initialize an application * * @param string $code * @param string $type * @param string|array $options */ public static function initApp($code = '', $type = 'store', $options = array()) { include BP . '/lib/Varien/Object.php'; include BP . '/app/code/core/Mage/Core/Model/App.php'; include BP . '/app/code/core/Mage/Core/Model/App_Area.php'; include BP . '/app/code/core/Mage/Core/Model/Config.php'; include BP . '/app/code/core/Mage/Core/Model/Store.php'; include BP . '/lib/Varien/Event/Collection.php'; if (VPROF) { Varien_Profiler::start('mage::app::construct'); } self::$_app = new Mage_Core_Model_App(); if (VPROF) { Varien_Profiler::stop('mage::app::construct'); } AO::setRoot(); AO::register('events', new Varien_Event_Collection()); if (VPROF) { Varien_Profiler::start('mage::app::register_config'); } AO::$_coreConfig = new Mage_Core_Model_Config(); if (VPROF) { Varien_Profiler::stop('mage::app::register_config'); } if (VPROF) { Varien_Profiler::start('mage::app::init'); } self::$_app->init($code, $type, $options); if (VPROF) { Varien_Profiler::stop('mage::app::init'); } self::$_app->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS); }
/** * 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; }
/** * Get initialized application object. * * @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) { self::$_app = new Mage_Core_Model_App(); self::setRoot(); self::$_events = new Varien_Event_Collection(); self::$_config = new Mage_Core_Model_Config($options); Varien_Profiler::start('self::app::init'); self::$_app->init($code, $type, $options); Varien_Profiler::stop('self::app::init'); self::$_app->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS); } return self::$_app; }