本文整理汇总了PHP中Magento\Framework\Cache\FrontendInterface类的典型用法代码示例。如果您正苦于以下问题:PHP FrontendInterface类的具体用法?PHP FrontendInterface怎么用?PHP FrontendInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FrontendInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param \Magento\Framework\Config\ReaderInterface $reader
* @param \Magento\Framework\Config\ScopeListInterface $scopeList
* @param \Magento\Framework\Cache\FrontendInterface $cache
* @param \Magento\Framework\ObjectManager\Relations $relations
* @param \Magento\Framework\Interception\ObjectManager\Config $omConfig
* @param \Magento\Framework\ObjectManager\Definition $classDefinitions
* @param string $cacheId
*/
public function __construct(\Magento\Framework\Config\ReaderInterface $reader, \Magento\Framework\Config\ScopeListInterface $scopeList, \Magento\Framework\Cache\FrontendInterface $cache, \Magento\Framework\ObjectManager\Relations $relations, \Magento\Framework\Interception\ObjectManager\Config $omConfig, \Magento\Framework\ObjectManager\Definition $classDefinitions, $cacheId = 'interception')
{
$this->_omConfig = $omConfig;
$this->_relations = $relations;
$this->_classDefinitions = $classDefinitions;
$this->_cache = $cache;
$this->_cacheId = $cacheId;
$this->_reader = $reader;
$intercepted = $this->_cache->load($this->_cacheId);
if ($intercepted !== false) {
$this->_intercepted = unserialize($intercepted);
} else {
$config = array();
foreach ($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(ltrim($typeName, '\\'));
}
foreach ($classDefinitions->getClasses() as $class) {
$this->hasPlugins($class);
}
$this->_cache->save(serialize($this->_intercepted), $this->_cacheId);
}
}
示例2: testCleanModeMatchingAnyTag
/**
* @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);
}
示例3: aroundDispatch
/**
* @param \Magento\Framework\App\FrontController $subject
* @param callable $proceed
* @param \Magento\Framework\App\RequestInterface $request
*
* @return \Magento\Framework\App\ResponseInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundDispatch(\Magento\Framework\App\FrontController $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
{
if ($this->_appState->isInstalled() && !$this->_cache->load('data_upgrade')) {
$this->_dbUpdater->updateScheme();
$this->_dbUpdater->updateData();
$this->_cache->save('true', 'data_upgrade');
}
return $proceed($request);
}
示例4: _afterSave
/**
* 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);
}
示例5: aroundDispatch
/**
* @param \Magento\Framework\App\FrontController $subject
* @param \Closure $proceed
* @param \Magento\Framework\App\RequestInterface $request
*
* @throws \Magento\Framework\Module\Exception
* @return \Magento\Framework\App\ResponseInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundDispatch(\Magento\Framework\App\FrontController $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
{
if (!$this->cache->load('db_is_up_to_date')) {
if (!$this->isDbUpToDate()) {
throw new \Magento\Framework\Module\Exception('Looks like database is outdated. Please, use setup tool to perform update');
} else {
$this->cache->save('true', 'db_is_up_to_date');
}
}
return $proceed($request);
}
示例6: _initializeConfigList
/**
* Init cached list of validation files
*/
protected function _initializeConfigList()
{
if (!$this->_configFiles) {
$this->_configFiles = $this->cache->load(self::CACHE_KEY);
if (!$this->_configFiles) {
$this->_configFiles = $this->moduleReader->getConfigurationFiles('validation.xml');
$this->cache->save(serialize($this->_configFiles), self::CACHE_KEY);
} else {
$this->_configFiles = unserialize($this->_configFiles);
}
}
}
示例7: load
/**
* Load modules DI configuration
*
* @param string $area
* @return array
*/
public function load($area)
{
$cacheId = $area . '::DiConfig';
$data = $this->_cache->load($cacheId);
if (!$data) {
$data = $this->_reader->read($area);
$this->_cache->save(serialize($data), $cacheId);
} else {
$data = unserialize($data);
}
return $data;
}
示例8: fetchAll
/**
* {@inheritdoc}
*/
public function fetchAll(\Zend_Db_Select $select, array $bindParams = array())
{
$cacheId = $this->_getSelectCacheId($select);
$result = $this->_cache->load($cacheId);
if ($result) {
$result = unserialize($result);
} else {
$result = $this->_fetchStrategy->fetchAll($select, $bindParams);
$this->_cache->save(serialize($result), $cacheId, $this->_cacheTags, $this->_cacheLifetime);
}
return $result;
}
示例9: aroundDispatch
/**
* @param \Magento\Framework\App\FrontController $subject
* @param \Closure $proceed
* @param \Magento\Framework\App\RequestInterface $request
*
* @throws \Magento\Framework\Exception\LocalizedException
* @return \Magento\Framework\App\ResponseInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundDispatch(\Magento\Framework\App\FrontController $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
{
if (!$this->cache->load('db_is_up_to_date')) {
$errors = $this->dbVersionInfo->getDbVersionErrors();
if ($errors) {
$formattedErrors = $this->formatErrors($errors);
throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Please upgrade your database: Run "bin/magento setup:upgrade" from the Magento root directory.' . ' %1The following modules are outdated:%2%3', [PHP_EOL, PHP_EOL, implode(PHP_EOL, $formattedErrors)]));
} else {
$this->cache->save('true', 'db_is_up_to_date');
}
}
return $proceed($request);
}
示例10: aroundDispatch
/**
* @param \Magento\Framework\App\FrontController $subject
* @param \Closure $proceed
* @param \Magento\Framework\App\RequestInterface $request
*
* @throws \Magento\Framework\Module\Exception
* @return \Magento\Framework\App\ResponseInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundDispatch(\Magento\Framework\App\FrontController $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
{
if (!$this->cache->load('db_is_up_to_date')) {
$errors = $this->dbVersionInfo->getDbVersionErrors();
if ($errors) {
$formattedErrors = $this->formatErrors($errors);
throw new \Magento\Framework\Module\Exception('Please update your database: Run "php -f index.php update" from the Magento root/setup directory.' . PHP_EOL . 'The following modules are outdated:' . PHP_EOL . implode(PHP_EOL, $formattedErrors));
} else {
$this->cache->save('true', 'db_is_up_to_date');
}
}
return $proceed($request);
}
示例11: getMethodsMap
/**
* Return service interface or Data interface methods loaded from cache
*
* @param string $interfaceName
* @return array
* <pre>
* Service methods' reflection data stored in cache as 'methodName' => 'returnType'
* ex.
* [
* 'create' => '\Magento\Customer\Api\Data\Customer',
* 'validatePassword' => 'boolean'
* ]
* </pre>
*/
public function getMethodsMap($interfaceName)
{
$key = self::SERVICE_INTERFACE_METHODS_CACHE_PREFIX . "-" . md5($interfaceName);
if (!isset($this->serviceInterfaceMethodsMap[$key])) {
$methodMap = $this->cache->load($key);
if ($methodMap) {
$this->serviceInterfaceMethodsMap[$key] = unserialize($methodMap);
} else {
$methodMap = $this->getMethodMapViaReflection($interfaceName);
$this->serviceInterfaceMethodsMap[$key] = $methodMap;
$this->cache->save(serialize($this->serviceInterfaceMethodsMap[$key]), $key);
}
}
return $this->serviceInterfaceMethodsMap[$key];
}
示例12: testGetData
/**
* @param $data
* @param $result
* @dataProvider dataProviderForTestGetData
*/
public function testGetData($data, $result)
{
$this->cache->expects($this->once())->method('load')->will($this->returnValue(serialize($data)));
$this->expectsSetConfig('themeId');
$this->translate->loadData('frontend');
$this->assertEquals($result, $this->translate->getData());
}
示例13: assignToStore
/**
* 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;
}
示例14: testGenerateElementsWithCache
public function testGenerateElementsWithCache()
{
$layoutCacheId = 'layout_cache_id';
/** @var \Magento\Framework\View\Layout\Element $xml */
$xml = simplexml_load_string('<layout/>', 'Magento\Framework\View\Layout\Element');
$this->model->setXml($xml);
$themeMock = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface');
$this->themeResolverMock->expects($this->once())
->method('get')
->willReturn($themeMock);
$this->processorFactoryMock->expects($this->once())
->method('create')
->with(['theme' => $themeMock])
->willReturn($this->processorMock);
$this->processorMock->expects($this->once())
->method('getCacheId')
->willReturn($layoutCacheId);
$readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context')
->disableOriginalConstructor()
->getMock();
$this->cacheMock->expects($this->once())
->method('load')
->with('structure_' . $layoutCacheId)
->willReturn(serialize($readerContextMock));
$this->readerPoolMock->expects($this->never())
->method('interpret');
$this->cacheMock->expects($this->never())
->method('save');
$generatorContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context')
->disableOriginalConstructor()
->getMock();
$this->generatorContextFactoryMock->expects($this->once())
->method('create')
->with(['structure' => $this->structureMock, 'layout' => $this->model])
->willReturn($generatorContextMock);
$this->generatorPoolMock->expects($this->once())
->method('process')
->with($readerContextMock, $generatorContextMock)
->willReturn(true);
$elements = [
'name_1' => ['type' => '', 'parent' => null],
'name_2' => ['type' => \Magento\Framework\View\Layout\Element::TYPE_CONTAINER, 'parent' => null],
'name_3' => ['type' => '', 'parent' => 'parent'],
'name_4' => ['type' => \Magento\Framework\View\Layout\Element::TYPE_CONTAINER, 'parent' => 'parent'],
];
$this->structureMock->expects($this->once())
->method('exportElements')
->willReturn($elements);
$this->model->generateElements();
}
示例15: testPersist
public function testPersist()
{
$cacheTypes = array('cache_type' => false);
$model = $this->_buildModel($cacheTypes);
$this->_resource->expects($this->once())->method('saveAllOptions')->with($cacheTypes);
$this->_cacheFrontend->expects($this->once())->method('remove')->with(\Magento\Framework\App\Cache\State::CACHE_ID);
$model->persist();
}