Пример #1
0
 /**
  * Update a "layout update link" if relevant data is provided
  *
  * @param \Magento\Widget\Model\Layout\Update|\Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $data = $object->getData();
     if (isset($data['store_id']) && isset($data['theme_id'])) {
         $this->getConnection()->insertOnDuplicate($this->getTable('layout_link'), ['store_id' => $data['store_id'], 'theme_id' => $data['theme_id'], 'layout_update_id' => $object->getId(), 'is_temporary' => (int) $object->getIsTemporary()]);
     }
     $this->_cache->clean();
     return parent::_afterSave($object);
 }
Пример #2
0
 /**
  * Assign theme to the stores
  *
  * @param \Magento\Framework\View\Design\ThemeInterface $theme
  * @param array $stores
  * @param string $scope
  * @return $this
  */
 public function assignToStore($theme, array $stores = [], $scope = \Magento\Store\Model\ScopeInterface::SCOPE_STORES)
 {
     $isReassigned = false;
     $this->_unassignThemeFromStores($theme->getId(), $stores, $scope, $isReassigned);
     if ($this->_storeManager->isSingleStoreMode()) {
         $this->_assignThemeToDefaultScope($theme->getId(), $isReassigned);
     } else {
         $this->_assignThemeToStores($theme->getId(), $stores, $scope, $isReassigned);
     }
     if ($isReassigned) {
         $this->_configCache->clean();
         $this->_layoutCache->clean();
     }
     $this->_eventManager->dispatch('assign_theme_to_stores_after', ['stores' => $stores, 'scope' => $scope, 'theme' => $theme]);
     return $this;
 }
Пример #3
0
 /**
  * Deletes all items in the pool.
  *
  * @return bool
  *   True if the pool was successfully cleared. False if there was an error.
  */
 public function clear()
 {
     if (empty($this->tags)) {
         return false;
     }
     return $this->cacheFrontend->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, $this->tags);
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function reinitStores()
 {
     $this->currentStoreId = null;
     $this->storeRepository->clean();
     $this->websiteRepository->clean();
     $this->groupRepository->clean();
     $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [StoreResolver::CACHE_TAG]);
 }
Пример #5
0
 /**
  * Clean cached data by specific tag
  *
  * @param array $tags
  * @return bool
  */
 public function clean($tags = array())
 {
     if ($tags) {
         $result = $this->_frontend->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, (array) $tags);
     } else {
         /** @deprecated special case of cleaning by empty tags is deprecated after 2.0.0.0-dev42 */
         $result = false;
         /** @var $cacheFrontend \Magento\Framework\Cache\FrontendInterface */
         foreach ($this->_frontendPool as $cacheFrontend) {
             if ($cacheFrontend->clean()) {
                 $result = true;
             }
         }
     }
     return $result;
 }
Пример #6
0
 /**
  * Initialize interception config
  *
  * @param array $classDefinitions
  * @return void
  */
 public function initialize($classDefinitions = [])
 {
     $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [$this->_cacheId]);
     $config = [];
     foreach ($this->_scopeList->getAllScopes() as $scope) {
         $config = array_replace_recursive($config, $this->_reader->read($scope));
     }
     unset($config['preferences']);
     foreach ($config as $typeName => $typeConfig) {
         if (!empty($typeConfig['plugins'])) {
             $this->_intercepted[ltrim($typeName, '\\')] = true;
         }
     }
     foreach ($config as $typeName => $typeConfig) {
         $this->hasPlugins($typeName);
     }
     foreach ($classDefinitions as $class) {
         $this->hasPlugins($class);
     }
     $this->_cache->save(serialize($this->_intercepted), $this->_cacheId);
 }
Пример #7
0
 /**
  * Advanced save procedure
  *
  * @return void
  */
 protected function _saveAdvanced()
 {
     $this->_cache->clean();
 }
 function it_does_not_clear_cache_if_no_tags_specified_to_prevent_full_cache_flush()
 {
     $this->cacheFrontend->clean(Argument::any(), Argument::any())->shouldNotBeCalled();
     $this->beConstructedWith($this->cacheItemFactory, $this->cacheFrontend, 'prefix_', []);
     $this->clear()->shouldReturn(false);
 }
Пример #9
0
 /**
  * Reset cached DDL data from cache
  * if table name is null - reset all cached DDL data
  *
  * @param string $tableName
  * @param string $schemaName OPTIONAL
  * @return $this
  */
 public function resetDdlCache($tableName = null, $schemaName = null)
 {
     if (!$this->_isDdlCacheAllowed) {
         return $this;
     }
     if ($tableName === null) {
         $this->_ddlCache = array();
         if ($this->_cacheAdapter) {
             $this->_cacheAdapter->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(self::DDL_CACHE_TAG));
         }
     } else {
         $cacheKey = $this->_getTableName($tableName, $schemaName);
         $ddlTypes = array(self::DDL_DESCRIBE, self::DDL_CREATE, self::DDL_INDEX, self::DDL_FOREIGN_KEY);
         foreach ($ddlTypes as $ddlType) {
             unset($this->_ddlCache[$ddlType][$cacheKey]);
         }
         if ($this->_cacheAdapter) {
             foreach ($ddlTypes as $ddlType) {
                 $cacheId = $this->_getCacheId($cacheKey, $ddlType);
                 $this->_cacheAdapter->remove($cacheId);
             }
         }
     }
     return $this;
 }
Пример #10
0
 /**
  * Clear cache of all scopes
  *
  * @return void
  */
 public function clean()
 {
     $this->_scopes = [];
     $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [self::CACHE_TAG]);
 }
Пример #11
0
 /**
  * Process role after saving
  *
  * @param \Magento\Framework\Model\AbstractModel $role
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $role)
 {
     $this->_updateRoleUsersAcl($role);
     $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(\Magento\Backend\Block\Menu::CACHE_TAGS));
     return $this;
 }
Пример #12
0
 /**
  * {@inheritdoc}
  */
 public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, array $tags = array())
 {
     return $this->_frontend->clean($mode, $tags);
 }
Пример #13
0
 /**
  * Clear cache of all scopes
  *
  * @return void
  */
 public function clean()
 {
     $this->_scopes = array();
     $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(self::CACHE_TAG));
 }