本文整理汇总了PHP中Magento\PageCache\Model\Config::isEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::isEnabled方法的具体用法?PHP Config::isEnabled怎么用?PHP Config::isEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\PageCache\Model\Config
的用法示例。
在下文中一共展示了Config::isEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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;
}
}
}
}
}
示例4: 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;
}
示例5: execute
/**
* Invalidate full page cache
*
* @return void
*/
public function execute()
{
if ($this->_config->isEnabled()) {
$this->_typeList->invalidate('full_page');
}
return $this;
}
示例6: isFullPageCacheEnabled
/**
* Is full page cache enabled
*
* @return bool
*/
protected function isFullPageCacheEnabled()
{
if ($this->isFullPageCacheEnabled === null) {
$this->isFullPageCacheEnabled = $this->_config->isEnabled();
}
return $this->isFullPageCacheEnabled;
}
示例7: aroundSave
/**
* @param \Magento\Catalog\Model\Resource\Attribute $subject
* @param callable $proceed
* @param \Magento\Framework\Model\AbstractModel $attribute
* @return mixed
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundSave(\Magento\Catalog\Model\Resource\Attribute $subject, \Closure $proceed, \Magento\Framework\Model\AbstractModel $attribute)
{
$result = $proceed($attribute);
if ($this->config->isEnabled()) {
$this->typeList->invalidate('full_page');
}
return $result;
}
示例8: execute
/**
* Invalidate full page cache if content is changed
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
if ($this->config->isEnabled()) {
$object = $observer->getEvent()->getObject();
if ($object instanceof \Magento\Framework\Object\IdentityInterface) {
if ($object->getIdentities()) {
$this->typeList->invalidate('full_page');
}
}
}
}
示例9: 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));
}
}
}
}
示例10: 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));
}
}
}
示例11: 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()]);
}
}
}
示例12: 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);
}
示例13: afterGetOutput
/**
* Set X-Cache-Tags header with all the Magento Cache Tags so
* they can be purged by the CloudFlare API
*
* @param \Magento\Framework\View\Layout $subject
* @param $result
* @return mixed
*/
public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result)
{
if (!$subject->isCacheable() || !$this->config->isEnabled()) {
return $result;
}
$tags = [];
foreach ($subject->getAllBlocks() as $block) {
if ($block->getIdentities() !== null) {
$tags = array_merge($tags, $block->getIdentities());
}
}
$tags = array_unique($tags);
$this->cacheTagsUtil->setCloudFlareCacheTagsResponseHeader($this->response, $tags);
return $result;
}
示例14: 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);
}
示例15: afterGetOutput
/**
* Retrieve all identities from blocks for further cache invalidation
*
* @param \Magento\Framework\View\Layout $subject
* @param mixed $result
* @return mixed
*/
public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result)
{
if ($subject->isCacheable() && $this->config->isEnabled()) {
$tags = [];
foreach ($subject->getAllBlocks() as $block) {
if ($block instanceof \Magento\Framework\DataObject\IdentityInterface) {
$isEsiBlock = $block->getTtl() > 0;
$isVarnish = $this->config->getType() == \Magento\PageCache\Model\Config::VARNISH;
if ($isVarnish && $isEsiBlock) {
continue;
}
$tags = array_merge($tags, $block->getIdentities());
}
}
$tags = array_unique($tags);
$this->response->setHeader('X-Magento-Tags', implode(',', $tags));
}
return $result;
}