/** * Remove configuration data after delete store * * @param \Magento\Framework\Model\AbstractModel $model * @return $this */ protected function _afterDelete(\Magento\Framework\Model\AbstractModel $model) { $where = ['scope = ?' => \Magento\Store\Model\ScopeInterface::SCOPE_STORES, 'scope_id = ?' => $model->getStoreId()]; $this->getConnection()->delete($this->getTable('core_config_data'), $where); $this->configCache->clean(); return $this; }
/** * @param bool $fixtureResultOne * @param bool $fixtureResultTwo * @param bool $expectedResult * @dataProvider cleanModeMatchingAnyTagDataProvider */ public function testCleanModeMatchingAnyTag($fixtureResultOne, $fixtureResultTwo, $expectedResult) { $this->frontendMock->expects($this->at(0))->method('clean')->with(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, ['test_tag_one', \Magento\Framework\App\Cache\Type\Config::CACHE_TAG])->will($this->returnValue($fixtureResultOne)); $this->frontendMock->expects($this->at(1))->method('clean')->with(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, ['test_tag_two', \Magento\Framework\App\Cache\Type\Config::CACHE_TAG])->will($this->returnValue($fixtureResultTwo)); $actualResult = $this->model->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, ['test_tag_one', 'test_tag_two']); $this->assertEquals($expectedResult, $actualResult); }
/** * Add Link to Head * * @return void */ protected function addHeadInclude() { $styleContent = ''; foreach ($this->moduleList->getNames() as $moduleName) { $fileName = substr($moduleName, strpos($moduleName, "_") + 1) . '/styles.css'; $fileName = $this->fixtureHelper->getPath($fileName); if (!$fileName) { continue; } $style = file_get_contents($fileName); $styleContent .= preg_replace('/^\\/\\*[\\s\\S]+\\*\\//', '', $style); } if (empty($styleContent)) { return; } $mediaDir = $this->directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA); file_put_contents("{$mediaDir}/styles.css", $styleContent); $linkTemplate = '<link rel="stylesheet" type="text/css" media="all" href="%sstyles.css" />'; $baseUrl = $this->baseUrl->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]); $linkText = sprintf($linkTemplate, $baseUrl); $miscScriptsNode = 'design/head/includes'; $miscScripts = $this->scopeConfig->getValue($miscScriptsNode); if (!$miscScripts || strpos($miscScripts, $linkText) === false) { $this->configWriter->save($miscScriptsNode, $miscScripts . $linkText); $this->configCacheType->clean(); } }
public function add($contentFile, $cssFile) { $styleContent = preg_replace('/^\\/\\*[\\s\\S]+\\*\\//', '', file_get_contents($contentFile)); if (empty($styleContent)) { return; } $mediaDir = $this->directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA); file_put_contents("{$mediaDir}/{$cssFile}", $styleContent, FILE_APPEND); $linkText = sprintf('<link rel="stylesheet" type="text/css" media="all" href="{{MEDIA_URL}}%s" />', $cssFile); $miscScriptsNode = 'design/head/includes'; $miscScripts = $this->scopeConfig->getValue($miscScriptsNode); if (!$miscScripts || strpos($miscScripts, $linkText) === false) { $this->configWriter->save($miscScriptsNode, $miscScripts . $linkText); $this->configCacheType->clean(); } }
/** * {@inheritdoc} */ public function run() { $this->logger->log('Installing multiple wishlists:'); $multipleEnabledConfig = 'wishlist/general/multiple_enabled'; if (!$this->config->isSetFlag($multipleEnabledConfig)) { $this->configWriter->save($multipleEnabledConfig, 1); $this->configCacheType->clean(); } $fixtureFiles = ['Wishlist/wishlist.csv', 'MultipleWishlist/wishlist.csv']; foreach ($fixtureFiles as $fixtureFile) { $fixtureFilePath = $this->fixtureHelper->getPath($fixtureFile); /** @var \Magento\SampleData\Helper\Csv\Reader $csvReader */ $csvReader = $this->csvReaderFactory->create(['fileName' => $fixtureFilePath, 'mode' => 'r']); foreach ($csvReader as $row) { /** @var \Magento\Customer\Model\Customer $customer */ $customer = $this->wishlistHelper->getCustomerByEmail($row['customer_email']); if (!$customer) { continue; } $wishlistName = $row['name']; /** @var \Magento\Wishlist\Model\Resource\Wishlist\Collection $wishlistCollection */ $wishlistCollection = $this->wishlistColFactory->create(); $wishlistCollection->filterByCustomerId($customer->getId())->addFieldToFilter('name', $wishlistName); /** @var \Magento\Wishlist\Model\Wishlist $wishlist */ $wishlist = $wishlistCollection->fetchItem(); if ($wishlist) { continue; } $wishlist = $this->wishlistEditor->edit($customer->getId(), $wishlistName, true); if (!$wishlist->getId()) { continue; } $productSkuList = explode("\n", $row['product_list']); $this->wishlistHelper->addProductsToWishlist($wishlist, $productSkuList); $this->logger->logInline('.'); } } }
/** * Rewrite in order to clear configuration cache * * @return $this */ public function afterDelete() { parent::afterDelete(); $this->_configCacheType->clean(); return $this; }
/** * Rewrite in order to clear configuration cache * * @return $this */ public function afterDelete() { parent::afterDelete(); $this->_configCacheType->clean(); if ($this->getId() === $this->getGroup()->getDefaultStoreId()) { $ids = $this->getGroup()->getStoreIds(); if (!empty($ids) && count($ids) > 1) { unset($ids[$this->getId()]); $defaultId = current($ids); } else { $defaultId = null; } $this->getGroup()->setDefaultStoreId($defaultId); $this->getGroup()->save(); } return $this; }
/** * Rewrite in order to clear configuration cache * * @return $this */ protected function _afterDelete() { parent::_afterDelete(); $this->_configCacheType->clean(); return $this; }