Esempio n. 1
0
 /**
  * @param array $arguments
  * @param string $className
  * @return Mage_Core_Model_Layout
  */
 public function createLayout(array $arguments = array(), $className = self::CLASS_NAME)
 {
     // because layout singleton was used everywhere in magento code, in observers, models, blocks, etc.
     // the only way how we can replace default layout object with custom one is to save instance of custom layout
     // to instance manager storage using default layout class name as alias
     $createLayout = true;
     if (isset($arguments['area'])) {
         if ($this->_objectManager->hasSharedInstance(self::CLASS_NAME)) {
             /** @var $layout Mage_Core_Model_Layout */
             $layout = $this->_objectManager->get(self::CLASS_NAME);
             if ($arguments['area'] != $layout->getArea()) {
                 $this->_objectManager->removeSharedInstance(self::CLASS_NAME);
             } else {
                 $createLayout = false;
             }
         }
     }
     if ($createLayout) {
         $layout = $this->_objectManager->create($className, $arguments, false);
         $this->_objectManager->addSharedInstance($layout, self::CLASS_NAME);
     }
     return $this->_objectManager->get(self::CLASS_NAME);
 }
Esempio n. 2
0
 /**
  * Initialize application cache instance
  *
  * @param array $cacheInitOptions
  * @return Mage_Core_Model_App
  */
 protected function _initCache(array $cacheInitOptions = array())
 {
     $this->_isCacheLocked = true;
     $options = $this->_config->getNode('global/cache');
     if ($options) {
         $options = $options->asArray();
     } else {
         $options = array();
     }
     $options = array_merge($options, $cacheInitOptions);
     $this->_cache = $this->_objectManager->create('Mage_Core_Model_Cache', array('options' => $options), false);
     $this->_objectManager->addSharedInstance($this->_cache, 'Mage_Core_Model_Cache');
     $this->_isCacheLocked = false;
     return $this;
 }