コード例 #1
0
 /**
  * Assign theme to the stores
  *
  * @param int $themeId
  * @param array $stores
  * @param string $scope
  * @param string $area
  * @return Mage_Core_Model_Theme
  * @throws UnexpectedValueException
  */
 public function assignThemeToStores($themeId, array $stores = array(), $scope = Mage_Core_Model_Config::SCOPE_STORES, $area = Mage_Core_Model_App_Area::AREA_FRONTEND)
 {
     /** @var $theme Mage_Core_Model_Theme */
     $theme = $this->_themeFactory->create()->load($themeId);
     if (!$theme->getId()) {
         throw new UnexpectedValueException('Theme is not recognized. Requested id: ' . $themeId);
     }
     $themeCustomization = $theme->isVirtual() ? $theme : $this->createThemeCustomization($theme);
     $configPath = $this->_design->getConfigPathByArea($area);
     // Unassign given theme from stores that were unchecked
     /** @var $config Mage_Core_Model_Config_Data */
     foreach ($this->_getAssignedScopesCollection($scope, $configPath) as $config) {
         if ($config->getValue() == $themeId && !in_array($config->getScopeId(), $stores)) {
             $this->_app->getConfig()->deleteConfig($configPath, $scope, $config->getScopeId());
         }
     }
     if (count($stores) > 0) {
         foreach ($stores as $storeId) {
             $this->_app->getConfig()->saveConfig($configPath, $themeCustomization->getId(), $scope, $storeId);
         }
         $this->_app->cleanCache(Mage_Core_Model_Config::CACHE_TAG);
     }
     $this->_makeTemporaryLayoutUpdatesPermanent($themeId, $stores);
     $this->_app->cleanCache(array('layout', Mage_Core_Model_Layout_Merge::LAYOUT_GENERAL_CACHE_TAG));
     $this->_eventManager->dispatch('assign_theme_to_stores_after', array('themeService' => $this, 'themeId' => $themeId, 'stores' => $stores, 'scope' => $scope, 'area' => $area, 'theme' => $theme, 'themeCustomization' => $themeCustomization));
     return $themeCustomization;
 }
コード例 #2
0
ファイル: AppTest.php プロジェクト: nemphys/magento2
 public function testCleanCache()
 {
     $this->assertEmpty($this->_mageModel->loadCache('test_id'));
     $this->_mageModel->saveCache('test_data', 'test_id', array('test_tag'));
     $this->assertEquals('test_data', $this->_mageModel->loadCache('test_id'));
     $this->_mageModel->cleanCache(array('test_tag'));
     $this->assertEmpty($this->_mageModel->loadCache('test_id'));
 }
コード例 #3
0
ファイル: Console.php プロジェクト: okite11/frames21
 /**
  * Install Magento
  *
  * @return boolean
  */
 public function install()
 {
     try {
         /**
          * Check if already installed
          */
         if (Mage::isInstalled()) {
             $this->addError('ERROR: Magento is already installed');
             return false;
         }
         /**
          * Skip URL validation, if set
          */
         $this->_getDataModel()->setSkipUrlValidation($this->_args['skip_url_validation']);
         $this->_getDataModel()->setSkipBaseUrlValidation($this->_args['skip_url_validation']);
         /**
          * Prepare data
          */
         $this->_prepareData();
         if ($this->hasErrors()) {
             return false;
         }
         $installer = $this->_getInstaller();
         /**
          * Install configuration
          */
         $installer->installConfig($this->_getDataModel()->getConfigData());
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Reinitialize configuration (to use new config data)
          */
         $this->_app->cleanCache();
         Mage::getConfig()->reinit();
         /**
          * Install database
          */
         $installer->installDb();
         if ($this->hasErrors()) {
             return false;
         }
         // apply data updates
         Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
         /**
          * Validate entered data for administrator user
          */
         $user = $installer->validateAndPrepareAdministrator($this->_getDataModel()->getAdminData());
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Prepare encryption key and validate it
          */
         $encryptionKey = empty($this->_args['encryption_key']) ? md5(Mage::helper('core')->getRandomString(10)) : $this->_args['encryption_key'];
         $this->_getDataModel()->setEncryptionKey($encryptionKey);
         $installer->validateEncryptionKey($encryptionKey);
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Create primary administrator user
          */
         $installer->createAdministrator($user);
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Save encryption key or create if empty
          */
         $installer->installEnryptionKey($encryptionKey);
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Installation finish
          */
         $installer->finish();
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Change directories mode to be writable by apache user
          */
         @chmod('var/cache', 0777);
         @chmod('var/session', 0777);
     } catch (Exception $e) {
         $this->addError('ERROR: ' . $e->getMessage());
         return false;
     }
     return true;
 }
コード例 #4
0
ファイル: Observer.php プロジェクト: hyhoocchan/mage-local
 /**
  * Cleaning cache
  *
  * @param string $tag
  */
 protected function _cleanCache($tag)
 {
     if ($this->_factory->getHelper('rss')->isRssEnabled()) {
         $this->_app->cleanCache(array($tag));
     }
 }
コード例 #5
0
 /**
  * Advanced save procedure
  */
 protected function _saveAdvanced()
 {
     $this->_app->cleanCache(array('layout', Mage_Core_Model_Layout_Merge::LAYOUT_GENERAL_CACHE_TAG));
 }
コード例 #6
0
 /**
  * Install Magento
  *
  * @return boolean
  */
 public function install()
 {
     try {
         /**
          * Check if already installed
          */
         if (AO::isInstalled()) {
             $this->addError('ERROR: Magento is already installed');
             return false;
         }
         /**
          * Skip URL validation, if set
          */
         $this->_getDataModel()->setSkipUrlValidation($this->_args['skip_url_validation']);
         $this->_getDataModel()->setSkipBaseUrlValidation($this->_args['skip_url_validation']);
         /**
          * Prepare data
          */
         $this->_prepareData();
         if ($this->hasErrors()) {
             return false;
         }
         $installer = $this->_getInstaller();
         /**
          * Install configuration
          */
         $installer->installConfig($this->_getDataModel()->getConfigData());
         // TODO fix wizard and simplify this everythere
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Reinitialize configuration (to use new config data)
          */
         $this->_app->cleanCache();
         AO::getConfig()->reinit();
         /**
          * Install database
          */
         $installer->installDb();
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Create primary administrator user
          */
         $installer->createAdministrator($this->_getDataModel()->getAdminData());
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Save encryption key or create if empty
          */
         $encryptionKey = empty($this->_args['encryption_key']) ? md5(time()) : $this->_args['encryption_key'];
         $this->_getDataModel()->setEncryptionKey($encryptionKey);
         $installer->installEnryptionKey($encryptionKey);
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Installation finish
          */
         $installer->finish();
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Change directories mode to be writable by apache user
          */
         @chmod('var/cache', 0777);
         @chmod('var/session', 0777);
     } catch (Exception $e) {
         $this->addError('ERROR: ' . $e->getMessage());
         return false;
     }
     return true;
 }