本文整理汇总了PHP中Magento\Framework\App\Cache\TypeListInterface::cleanType方法的典型用法代码示例。如果您正苦于以下问题:PHP TypeListInterface::cleanType方法的具体用法?PHP TypeListInterface::cleanType怎么用?PHP TypeListInterface::cleanType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Cache\TypeListInterface
的用法示例。
在下文中一共展示了TypeListInterface::cleanType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Toggle cache
*
*/
public function execute()
{
$allTypes = array_keys($this->_cacheTypeList->getTypes());
$updatedTypes = 0;
$disable = true;
$enable = true;
foreach ($allTypes as $code) {
if ($this->_cacheState->isEnabled($code) && $disable) {
$this->_cacheState->setEnabled($code, false);
$updatedTypes++;
$enable = false;
}
if (!$this->_cacheState->isEnabled($code) && $enable) {
$this->_cacheState->setEnabled($code, true);
$updatedTypes++;
$disable = false;
}
if ($disable) {
$this->_cacheTypeList->cleanType($code);
}
}
if ($updatedTypes > 0) {
$this->_cacheState->persist();
$this->messageManager->addSuccess(__("%1 cache type(s) disabled.", $updatedTypes));
}
}
示例2: install
/**
* {@inheritdoc}
*/
public function install(array $fixtures)
{
/** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter */
$adapter = $this->resource->getConnection('core_write');
$regions = $this->loadDirectoryRegions();
foreach ($fixtures as $fileName) {
$fileName = $this->fixtureManager->getFixture($fileName);
if (!file_exists($fileName)) {
continue;
}
$rows = $this->csvReader->getData($fileName);
$header = array_shift($rows);
foreach ($rows as $row) {
$data = [];
foreach ($row as $key => $value) {
$data[$header[$key]] = $value;
}
$regionId = $data['region'] != '*' ? $regions[$data['country']][$data['region']] : 0;
try {
$adapter->insert($this->tablerate->getMainTable(), ['website_id' => $this->storeManager->getWebsite()->getId(), 'dest_country_id' => $data['country'], 'dest_region_id' => $regionId, 'dest_zip' => $data['zip'], 'condition_name' => 'package_value', 'condition_value' => $data['order_subtotal'], 'price' => $data['price'], 'cost' => 0]);
} catch (\Zend_Db_Statement_Exception $e) {
if ($e->getCode() == self::ERROR_CODE_DUPLICATE_ENTRY) {
// In case if Sample data was already installed we just skip duplicated records installation
continue;
} else {
throw $e;
}
}
}
}
$this->configWriter->save('carriers/tablerate/active', 1);
$this->configWriter->save('carriers/tablerate/condition_name', 'package_value');
$this->cacheTypeList->cleanType('config');
}
示例3: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->logger->log('Installing Tablerate:');
/** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */
$connection = $this->resource->getConnection('core');
$fixtureFile = 'OfflineShipping/tablerate.csv';
$fixtureFilePath = $this->fixtureHelper->getPath($fixtureFile);
$regions = $this->loadDirectoryRegions();
/** @var \Magento\SampleData\Helper\Csv\Reader $csvReader */
$csvReader = $this->csvReaderFactory->create(['fileName' => $fixtureFilePath, 'mode' => 'r']);
foreach ($csvReader as $data) {
$regionId = $data['region'] != '*' ? $regions[$data['country']][$data['region']] : 0;
try {
$connection->insert($this->tablerate->getMainTable(), ['website_id' => $this->storeManager->getWebsiteId(), 'dest_country_id' => $data['country'], 'dest_region_id' => $regionId, 'dest_zip' => $data['zip'], 'condition_name' => 'package_value', 'condition_value' => $data['order_subtotal'], 'price' => $data['price'], 'cost' => 0]);
} catch (\Zend_Db_Statement_Exception $e) {
if ($e->getCode() == self::ERROR_CODE_DUPLICATE_ENTRY) {
// In case if Sample data was already installed we just skip duplicated records installation
continue;
} else {
throw $e;
}
}
$this->logger->logInline('.');
}
$this->configWriter->save('carriers/tablerate/active', 1);
$this->configWriter->save('carriers/tablerate/condition_name', 'package_value');
$this->cacheTypeList->cleanType('config');
}
示例4: execute
/**
* Set tax ignore notification flag and redirect back
*
* @return \Magento\Framework\App\ResponseInterface
*/
public function execute()
{
$section = $this->getRequest()->getParam('section');
if ($section) {
try {
$path = 'tax/notification/ignore_' . $section;
$this->_objectManager->get('Magento\\Config\\Model\\Resource\\Config')->saveConfig($path, 1, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, 0);
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
}
}
// clear the block html cache
$this->_cacheTypeList->cleanType('block_html');
$this->_eventManager->dispatch('adminhtml_cache_refresh_type', ['type' => 'block_html']);
$this->getResponse()->setRedirect($this->_redirect->getRefererUrl());
}
示例5: execute
/**
* Set tax ignore notification flag and redirect back
*
* @return \Magento\Backend\Model\View\Result\Redirect
*/
public function execute()
{
try {
$path = \ClassyLlama\AvaTax\Helper\Config::XML_PATH_AVATAX_ADMIN_NOTIFICATION_IGNORE_NATIVE_TAX_RULES;
$this->_objectManager->get('Magento\\Config\\Model\\ResourceModel\\Config')->saveConfig($path, 1, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
$this->messageManager->addSuccess('Notification successfully ignored');
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
}
// clear the block html cache
$this->cacheTypeList->cleanType('config');
$this->_eventManager->dispatch('adminhtml_cache_refresh_type', ['type' => 'block_html']);
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
return $resultRedirect->setRefererUrl();
}
示例6: execute
/**
* Set tax ignore notification flag and redirect back
*
* @return \Magento\Backend\Model\View\Result\Redirect
*/
public function execute()
{
$section = $this->getRequest()->getParam('section');
if ($section) {
try {
$path = 'tax/notification/ignore_' . $section;
$this->_objectManager->get('Magento\\Config\\Model\\ResourceModel\\Config')->saveConfig($path, 1, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
}
}
// clear the block html cache
$this->_cacheTypeList->cleanType('block_html');
$this->_eventManager->dispatch('adminhtml_cache_refresh_type', ['type' => 'block_html']);
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
return $resultRedirect->setRefererUrl();
}
示例7: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->logger->log('Installing Tablerate:');
/** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter */
$adapter = $this->resource->getConnection('core_write');
$fixtureFile = 'OfflineShipping/tablerate.csv';
$fixtureFilePath = $this->fixtureHelper->getPath($fixtureFile);
$regions = $this->loadDirectoryRegions();
/** @var \Magento\SampleData\Helper\Csv\Reader $csvReader */
$csvReader = $this->csvReaderFactory->create(['fileName' => $fixtureFilePath, 'mode' => 'r']);
foreach ($csvReader as $data) {
$regionId = $data['region'] != '*' ? $regions[$data['country']][$data['region']] : 0;
$adapter->insert($this->tablerate->getMainTable(), ['website_id' => $this->storeManager->getWebsiteId(), 'dest_country_id' => $data['country'], 'dest_region_id' => $regionId, 'dest_zip' => $data['zip'], 'condition_name' => 'package_value', 'condition_value' => $data['order_subtotal'], 'price' => $data['price'], 'cost' => 0]);
$this->logger->logInline('.');
}
$this->configWriter->save('carriers/tablerate/active', 1);
$this->configWriter->save('carriers/tablerate/condition_name', 'package_value');
$this->cacheTypeList->cleanType('config');
}
示例8: clean
/**
* Cleans up caches
*
* @param array $types
* @return void
*/
public function clean(array $types)
{
foreach ($types as $type) {
$this->cacheTypeList->cleanType($type);
}
}