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

PHP Model\Config类代码示例

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

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



在下文中一共展示了Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: isVarnishEnabled

 /**
  * Is varnish cache engine enabled
  *
  * @return bool
  */
 protected function isVarnishEnabled()
 {
     if ($this->isVarnishEnabled === null) {
         $this->isVarnishEnabled = $this->_config->getType() == \Magento\PageCache\Model\Config::VARNISH;
     }
     return $this->isVarnishEnabled;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:ProcessLayoutRenderElement.php


示例2: execute

 /**
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute(Observer $observer)
 {
     if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && $this->taxHelper->isCatalogPriceDisplayAffectedByTax()) {
         /** @var \Magento\Customer\Model\Data\Customer $customer */
         $customer = $observer->getData('customer');
         $customerGroupId = $customer->getGroupId();
         $customerGroup = $this->groupRepository->getById($customerGroupId);
         $customerTaxClassId = $customerGroup->getTaxClassId();
         $this->customerSession->setCustomerTaxClassId($customerTaxClassId);
         /** @var \Magento\Customer\Api\Data\AddressInterface[] $addresses */
         $addresses = $customer->getAddresses();
         if (isset($addresses)) {
             $defaultShippingFound = false;
             $defaultBillingFound = false;
             foreach ($addresses as $address) {
                 if ($address->isDefaultBilling()) {
                     $defaultBillingFound = true;
                     $this->customerSession->setDefaultTaxBillingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
                 }
                 if ($address->isDefaultShipping()) {
                     $defaultShippingFound = true;
                     $this->customerSession->setDefaultTaxShippingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
                 }
                 if ($defaultShippingFound && $defaultBillingFound) {
                     break;
                 }
             }
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:35,代码来源:CustomerLoggedInObserver.php


示例3: afterGenerateXml

 /**
  * After generate Xml
  *
  * @param \Magento\Framework\View\LayoutInterface $subject
  * @param \Magento\Framework\View\LayoutInterface $result
  * @return \Magento\Framework\View\LayoutInterface
  */
 public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result)
 {
     if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && !$this->request->isAjax() && $subject->isCacheable()) {
         $this->checkoutSession->clearStorage();
     }
     return $result;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:DepersonalizePlugin.php


示例4: testExportVarnishConfigAction

 public function testExportVarnishConfigAction()
 {
     $fileContent = 'some conetnt';
     $filename = 'varnish.vcl';
     $responseMock = $this->getMockBuilder('Magento\\Framework\\App\\ResponseInterface')->disableOriginalConstructor()->getMock();
     $this->configMock->expects($this->once())->method('getVclFile')->will($this->returnValue($fileContent));
     $this->fileFactoryMock->expects($this->once())->method('create')->with($this->equalTo($filename), $this->equalTo($fileContent), $this->equalTo(DirectoryList::VAR_DIR))->will($this->returnValue($responseMock));
     $result = $this->action->executeInternal();
     $this->assertInstanceOf('Magento\\Framework\\App\\ResponseInterface', $result);
 }
开发者ID:nblair,项目名称:magescotch,代码行数:10,代码来源:ExportVarnishConfigTest.php


示例5: execute

 /**
  * If Built-In caching is enabled it collects array of tags
  * of incoming object and asks to clean cache.
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_config->getType() == \Magento\PageCache\Model\Config::BUILT_IN && $this->_config->isEnabled()) {
         $object = $observer->getEvent()->getObject();
         if ($object instanceof \Magento\Framework\DataObject\IdentityInterface) {
             $tags = $object->getIdentities();
             if (!empty($tags)) {
                 $this->getCache()->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array_unique($tags));
             }
         }
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:FlushCacheByTags.php


示例6: testCheckIfDepersonalize

 /**
  * @param array $requestResult
  * @param bool $moduleManagerResult
  * @param bool $cacheConfigResult
  * @param bool $layoutResult
  * @param bool $can Depersonalize
  * @dataProvider checkIfDepersonalizeDataProvider
  */
 public function testCheckIfDepersonalize(array $requestResult, $moduleManagerResult, $cacheConfigResult, $layoutResult, $canDepersonalize)
 {
     $this->requestMock->expects($this->any())->method('isAjax')->willReturn($requestResult['ajax']);
     $this->requestMock->expects($this->any())->method('isGet')->willReturn($requestResult['get']);
     $this->requestMock->expects($this->any())->method('isHead')->willReturn($requestResult['head']);
     $this->moduleManagerMock->expects($this->any())->method('isEnabled')->with('Magento_PageCache')->willReturn($moduleManagerResult);
     $this->cacheConfigMock->expects($this->any())->method('isEnabled')->willReturn($cacheConfigResult);
     $layoutMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\LayoutInterface', [], '', false);
     $layoutMock->expects($this->any())->method('isCacheable')->willReturn($layoutResult);
     $object = new DepersonalizeChecker($this->requestMock, $this->moduleManagerMock, $this->cacheConfigMock);
     $this->assertEquals($canDepersonalize, $object->checkIfDepersonalize($layoutMock));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:DepersonalizeCheckerTest.php


示例7: execute

 /**
  * If Built-In caching is enabled it collects array of tags
  * of incoming object and asks to clean cache.
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_config->getType() == \Magento\PageCache\Model\Config::BUILT_IN && $this->_config->isEnabled()) {
         $object = $observer->getEvent()->getObject();
         if ($object instanceof \Magento\Framework\Object\IdentityInterface) {
             $tags = $object->getIdentities();
             foreach ($tags as $tag) {
                 $tags[] = preg_replace("~_\\d+\$~", '', $tag);
             }
             $this->_cache->clean(array_unique($tags));
         }
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:20,代码来源:FlushCacheByTags.php


示例8: aroundDispatch

 /**
  * @param \Magento\Framework\App\ActionInterface $subject
  * @param callable $proceed
  * @param \Magento\Framework\App\RequestInterface $request
  * @return mixed
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundDispatch(\Magento\Framework\App\ActionInterface $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
 {
     if (!$this->customerSession->isLoggedIn() || !$this->moduleManager->isEnabled('Magento_PageCache') || !$this->cacheConfig->isEnabled() || !$this->taxHelper->isCatalogPriceDisplayAffectedByTax()) {
         return $proceed($request);
     }
     $defaultBillingAddress = $this->customerSession->getDefaultTaxBillingAddress();
     $defaultShippingAddress = $this->customerSession->getDefaultTaxShippingAddress();
     $customerTaxClassId = $this->customerSession->getCustomerTaxClassId();
     if (!empty($defaultBillingAddress) || !empty($defaultShippingAddress)) {
         $taxRates = $this->taxCalculation->getTaxRates($defaultBillingAddress, $defaultShippingAddress, $customerTaxClassId);
         $this->httpContext->setValue('tax_rates', $taxRates, 0);
     }
     return $proceed($request);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:21,代码来源:ContextPlugin.php


示例9: testExecuteWithEmptyTags

 public function testExecuteWithEmptyTags()
 {
     $this->_configMock->expects($this->any())->method('isEnabled')->will($this->returnValue(true));
     $observerObject = $this->getMock('Magento\\Framework\\Event\\Observer');
     $observedObject = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $tags = [];
     $eventMock = $this->getMock('Magento\\Framework\\Event', ['getObject'], [], '', false);
     $eventMock->expects($this->once())->method('getObject')->will($this->returnValue($observedObject));
     $observerObject->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock));
     $this->_configMock->expects($this->once())->method('getType')->will($this->returnValue(\Magento\PageCache\Model\Config::BUILT_IN));
     $observedObject->expects($this->once())->method('getIdentities')->will($this->returnValue($tags));
     $this->_cacheMock->expects($this->never())->method('clean');
     $this->_model->execute($observerObject);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:FlushCacheByTagsTest.php


示例10: execute

 /**
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute(Observer $observer)
 {
     if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && $this->taxHelper->isCatalogPriceDisplayAffectedByTax()) {
         /** @var $customerAddress Address */
         $address = $observer->getCustomerAddress();
         // Check if the address is either the default billing, shipping, or both
         if ($this->isDefaultBilling($address)) {
             $this->customerSession->setDefaultTaxBillingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegionId() : null, 'postcode' => $address->getPostcode()]);
         }
         if ($this->isDefaultShipping($address)) {
             $this->customerSession->setDefaultTaxShippingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegionId() : null, 'postcode' => $address->getPostcode()]);
         }
     }
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:19,代码来源:AfterAddressSaveObserver.php


示例11: executeInternal

 /**
  * Export Varnish Configuration as .vcl
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function executeInternal()
 {
     $fileName = 'varnish.vcl';
     $varnishVersion = $this->getRequest()->getParam('varnish');
     switch ($varnishVersion) {
         case 3:
             $content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_3_CONFIGURATION_PATH);
             break;
         default:
             $content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_4_CONFIGURATION_PATH);
             break;
     }
     return $this->fileFactory->create($fileName, $content, DirectoryList::VAR_DIR);
 }
开发者ID:nblair,项目名称:magescotch,代码行数:19,代码来源:ExportVarnishConfig.php


示例12: aroundExecute

    /**
     * @param \Magento\Framework\App\ActionInterface $subject
     * @param callable $proceed
     * @param \Magento\Framework\App\RequestInterface $request
     * @return mixed
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     */
    public function aroundExecute(
        \Magento\Framework\App\ActionInterface $subject,
        \Closure $proceed,
        \Magento\Framework\App\RequestInterface $request
    ) {
        if (!$this->weeeHelper->isEnabled() ||
            !$this->customerSession->isLoggedIn() ||
            !$this->moduleManager->isEnabled('Magento_PageCache') ||
            !$this->cacheConfig->isEnabled()) {
            return $proceed($request);
        }

        $basedOn = $this->taxHelper->getTaxBasedOn();
        if ($basedOn != 'shipping' && $basedOn != 'billing') {
            return $proceed($request);
        }

        $weeeTaxRegion = $this->getWeeeTaxRegion($basedOn);
        $websiteId = $this->storeManager->getStore()->getWebsiteId();
        $countryId = $weeeTaxRegion['countryId'];
        $regionId = $weeeTaxRegion['regionId'];

        if (!$countryId && !$regionId) {
            // country and region does not exist
            return $proceed($request);
        } else if ($countryId && !$regionId) {
            // country exist and region does not exist
            $regionId = 0;
            $exist = $this->weeeTax->isWeeeInLocation(
                $countryId,
                $regionId,
                $websiteId
            );
        } else {
            // country and region exist
            $exist = $this->weeeTax->isWeeeInLocation(
                $countryId,
                $regionId,
                $websiteId
            );
            if (!$exist) {
                // just check the country for weee
                $regionId = 0;
                $exist = $this->weeeTax->isWeeeInLocation(
                    $countryId,
                    $regionId,
                    $websiteId
                );
            }
        }

        if ($exist) {
            $this->httpContext->setValue(
                'weee_tax_region',
                ['countryId' => $countryId, 'regionId' => $regionId],
                0
            );
        }
        return $proceed($request);
    }
开发者ID:nblair,项目名称:magescotch,代码行数:70,代码来源:ContextPlugin.php


示例13: testExecute

 /**
  * Test case for cache invalidation
  *
  * @dataProvider flushCacheByTagsDataProvider
  * @param $cacheState
  */
 public function testExecute($cacheState)
 {
     $this->_configMock->expects($this->any())->method('isEnabled')->will($this->returnValue($cacheState));
     $observerObject = $this->getMock('Magento\\Framework\\Event\\Observer');
     $observedObject = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     if ($cacheState) {
         $tags = ['cache_1', 'cache_group'];
         $expectedTags = ['cache_1', 'cache_group', 'cache'];
         $eventMock = $this->getMock('Magento\\Framework\\Event', ['getObject'], [], '', false);
         $eventMock->expects($this->once())->method('getObject')->will($this->returnValue($observedObject));
         $observerObject->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock));
         $this->_configMock->expects($this->once())->method('getType')->will($this->returnValue(\Magento\PageCache\Model\Config::BUILT_IN));
         $observedObject->expects($this->once())->method('getIdentities')->will($this->returnValue($tags));
         $this->_cacheMock->expects($this->once())->method('clean')->with($this->equalTo($expectedTags));
     }
     $this->_model->execute($observerObject);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:23,代码来源:FlushCacheByTagsTest.php


示例14: testAfterAddressSave

 public function testAfterAddressSave()
 {
     $this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
     $this->cacheConfigMock->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->taxHelperMock->expects($this->any())->method('isCatalogPriceDisplayAffectedByTax')->willReturn(true);
     $address = $this->objectManager->getObject('Magento\\Customer\\Model\\Address');
     $address->setIsDefaultShipping(true);
     $address->setIsDefaultBilling(true);
     $address->setIsPrimaryBilling(true);
     $address->setIsPrimaryShipping(true);
     $address->setCountryId(1);
     $address->setData('postcode', 11111);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxBillingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxShippingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->observerMock->expects($this->once())->method('getCustomerAddress')->willReturn($address);
     $this->session->afterAddressSave($this->observerMock);
 }
开发者ID:kid17,项目名称:magento2,代码行数:17,代码来源:SessionTest.php


示例15: testExecute

 /**
  * @param bool $cacheState
  * @param bool $varnishIsEnabled
  * @param bool $scopeIsPrivate
  * @param int|null $blockTtl
  * @param string $expectedOutput
  * @dataProvider processLayoutRenderDataProvider
  */
 public function testExecute($cacheState, $varnishIsEnabled, $scopeIsPrivate, $blockTtl, $expectedOutput)
 {
     $eventMock = $this->getMock('Magento\\Framework\\Event', ['getLayout', 'getElementName', 'getTransport'], [], '', false);
     $this->_observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock));
     $eventMock->expects($this->once())->method('getLayout')->will($this->returnValue($this->_layoutMock));
     $this->_configMock->expects($this->any())->method('isEnabled')->will($this->returnValue($cacheState));
     if ($cacheState) {
         $eventMock->expects($this->once())->method('getElementName')->will($this->returnValue('blockName'));
         $eventMock->expects($this->once())->method('getTransport')->will($this->returnValue($this->_transport));
         $this->_layoutMock->expects($this->once())->method('isCacheable')->will($this->returnValue(true));
         $this->_layoutMock->expects($this->any())->method('getUpdate')->will($this->returnSelf());
         $this->_layoutMock->expects($this->any())->method('getHandles')->will($this->returnValue([]));
         $this->_layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($this->_blockMock));
         if ($varnishIsEnabled) {
             $this->_blockMock->expects($this->once())->method('getData')->with('ttl')->will($this->returnValue($blockTtl));
             $this->_blockMock->expects($this->any())->method('getUrl')->will($this->returnValue('page_cache/block/wrapesi/with/handles/and/other/stuff'));
         }
         if ($scopeIsPrivate) {
             $this->_blockMock->expects($this->once())->method('getNameInLayout')->will($this->returnValue('testBlockName'));
             $this->_blockMock->expects($this->once())->method('isScopePrivate')->will($this->returnValue($scopeIsPrivate));
         }
         $this->_configMock->expects($this->any())->method('getType')->will($this->returnValue($varnishIsEnabled));
     }
     $this->_model->execute($this->_observerMock);
     $this->assertEquals($expectedOutput, $this->_transport['output']);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:34,代码来源:ProcessLayoutRenderElementTest.php


示例16: execute

 /**
  * Invalidate full page and block cache
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_config->isEnabled()) {
         $this->_typeList->invalidate(\Magento\PageCache\Model\Cache\Type::TYPE_IDENTIFIER);
     }
     $this->_typeList->invalidate(\Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER);
 }
开发者ID:magefan,项目名称:module-blog,代码行数:14,代码来源:InvalidateCache.php


示例17: afterExecute

 /**
  * @param AbstractAction $subject
  * @param AbstractAction $result
  * @return AbstractAction
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterExecute(AbstractAction $subject, AbstractAction $result)
 {
     if ($this->config->isEnabled()) {
         $this->typeList->invalidate('full_page');
     }
     return $result;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:Execute.php


示例18: execute

 /**
  * Invalidate full page cache
  *
  * @return void
  */
 public function execute()
 {
     if ($this->_config->isEnabled()) {
         $this->_typeList->invalidate('full_page');
     }
     return $this;
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:12,代码来源:InvalidateCache.php


示例19: testAfterExecuteInvalidate

 public function testAfterExecuteInvalidate()
 {
     $subject = $this->getMockBuilder('Magento\\Catalog\\Model\\Indexer\\Category\\Product\\AbstractAction')->disableOriginalConstructor()->getMockForAbstractClass();
     $result = $this->getMockBuilder('Magento\\Catalog\\Model\\Indexer\\Category\\Product\\AbstractAction')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->config->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->typeList->expects($this->once())->method('invalidate')->with('full_page');
     $this->assertEquals($result, $this->execute->afterExecute($subject, $result));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:8,代码来源:ExecuteTest.php


示例20: testAroundDispatchDisabled

 /**
  * @dataProvider dataProvider
  */
 public function testAroundDispatchDisabled($state)
 {
     $this->configMock->expects($this->any())->method('getType')->will($this->returnValue(null));
     $this->versionMock->expects($this->never())->method('process');
     $this->stateMock->expects($this->any())->method('getMode')->will($this->returnValue($state));
     $this->responseMock->expects($this->never())->method('setHeader');
     $this->plugin->aroundDispatch($this->frontControllerMock, $this->closure, $this->requestMock);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:VarnishPluginTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Helper\Data类代码示例发布时间:2022-05-23
下一篇:
PHP CurlTransport\BackendDecorator类代码示例发布时间: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