• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Cache\FrontendInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Framework\Cache\FrontendInterface的典型用法代码示例。如果您正苦于以下问题:PHP FrontendInterface类的具体用法?PHP FrontendInterface怎么用?PHP FrontendInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FrontendInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
     }
 }
开发者ID:,项目名称:,代码行数:40,代码来源:


示例2: clean

 /**
  * 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;
 }
开发者ID:,项目名称:,代码行数:22,代码来源:


示例3: 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);
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:13,代码来源:ConfigTest.php


示例4: 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);
 }
开发者ID:,项目名称:,代码行数:17,代码来源:


示例5: _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);
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:15,代码来源:Update.php


示例6: 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);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:20,代码来源:DbStatusValidator.php


示例7: _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);
         }
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:Factory.php


示例8: 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;
 }
开发者ID:,项目名称:,代码行数:18,代码来源:


示例9: 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;
 }
开发者ID:,项目名称:,代码行数:15,代码来源:


示例10: 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);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:22,代码来源:DbStatusValidator.php


示例11: 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);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:22,代码来源:DbStatusValidator.php


示例12: 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];
 }
开发者ID:opexsw,项目名称:magento2,代码行数:29,代码来源:MethodsMap.php


示例13: 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());
 }
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:12,代码来源:TranslateTest.php


示例14: 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;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:Config.php


示例15: 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();
    }
开发者ID:nja78,项目名称:magento2,代码行数:60,代码来源:LayoutTest.php


示例16: 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();
 }
开发者ID:,项目名称:,代码行数:8,代码来源:


示例17: save

 /**
  * Persists a cache item immediately.
  *
  * @param CacheItemInterface $item
  *   The cache item to save.
  *
  * @return bool
  *   True if the item was successfully persisted. False if there was an error.
  *
  * @throws InvalidArgumentException
  */
 public function save(CacheItemInterface $item)
 {
     $expirationTime = null;
     if ($item instanceof ExtractableCacheLifetimeInterface) {
         $expirationTime = $item->getCacheLifetime();
     }
     return $this->cacheFrontend->save(serialize($item instanceof ExtractableCacheValueInterface ? $item->getCacheValue() : $item->get()), $this->prepareKey($item->getKey()), $this->tags, $expirationTime);
 }
开发者ID:ecomdev,项目名称:magento-psr6-bridge,代码行数:19,代码来源:CacheItemPool.php


示例18: reinitStores

 /**
  * {@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]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:StoreManager.php


示例19: _getRoutes

 /**
  * Fetch routes from configs by area code and router id
  *
  * @param string $scope
  * @return array
  */
 protected function _getRoutes($scope = null)
 {
     $scope = $scope ?: $this->_configScope->getCurrentScope();
     if (isset($this->_routes[$scope])) {
         return $this->_routes[$scope];
     }
     $cacheId = $scope . '::' . $this->_cacheId;
     $cachedRoutes = unserialize($this->_cache->load($cacheId));
     if (is_array($cachedRoutes)) {
         $this->_routes[$scope] = $cachedRoutes;
         return $cachedRoutes;
     }
     $routers = $this->_reader->read($scope);
     $routes = $routers[$this->_areaList->getDefaultRouter($scope)]['routes'];
     $this->_cache->save(serialize($routes), $cacheId);
     $this->_routes[$scope] = $routes;
     return $routes;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:Config.php


示例20:

 function it_commits_deferred_cache_items_only_onces(CacheItemInterface $cacheItem)
 {
     $cacheItem->get()->willReturn([1, 2, 3])->shouldBeCalledTimes(1);
     $cacheItem->getKey()->willReturn('key1')->shouldBeCalledTimes(1);
     $this->cacheFrontend->save(serialize([1, 2, 3]), 'prefix_key1', ['tag1', 'tag2'], null)->willReturn(true)->shouldBeCalledTimes(1);
     $this->saveDeferred($cacheItem)->shouldReturn(true);
     $this->commit()->shouldReturn(true);
     // This time nothing should happen
     $this->commit()->shouldReturn(true);
 }
开发者ID:ecomdev,项目名称:magento-psr6-bridge,代码行数:10,代码来源:CacheItemPoolSpec.php



注:本文中的Magento\Framework\Cache\FrontendInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Component\ComponentRegistrar类代码示例发布时间:2022-05-23
下一篇:
PHP Utility\Files类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap