protected function setDefaultExtraCacheKeys(BlockContextInterface $blockContext, array $settings)
    {
        if (!$blockContext->getSetting('use_cache') || $blockContext->getSetting('ttl') <= 0) {
            return;
        }

        $block = $blockContext->getBlock();

        // type by block class
        $class = ClassUtils::getClass($block);
        $cacheServiceId = isset($this->cacheBlocks['by_class'][$class]) ? $this->cacheBlocks['by_class'][$class] : false;

        // type by block service
        if (!$cacheServiceId) {
            $cacheServiceId = isset($this->cacheBlocks['by_type'][$block->getType()]) ? $this->cacheBlocks['by_type'][$block->getType()] : false;
        }

        if (!$cacheServiceId) {
            // no context cache needed
            return;
        }

        // do not add cache settings to extra_cache_keys
        unset($settings['use_cache'], $settings['extra_cache_keys'], $settings['ttl']);

        $extraCacheKeys = $blockContext->getSetting('extra_cache_keys');

        // add context settings to extra_cache_keys
        if (!isset($extraCacheKeys[self::CACHE_KEY])) {
            $extraCacheKeys[self::CACHE_KEY] = $settings;
            $blockContext->setSetting('extra_cache_keys', $extraCacheKeys);
        }
    }
protected function setDefaultExtraCacheKeys(BlockContextInterface $blockContext, array $settings)
    {
        if (!$blockContext->getSetting('use_cache') || $blockContext->getSetting('ttl') <= 0) {
            return;
        }

        $block = $blockContext->getBlock();

        // type by block class
        $class = ClassUtils::getClass($block);
        $cacheServiceId = isset($this->cacheBlocks['by_class'][$class]) ? $this->cacheBlocks['by_class'][$class] : false;

        // type by block service
        if (!$cacheServiceId) {
            $cacheServiceId = isset($this->cacheBlocks['by_type'][$block->getType()]) ? $this->cacheBlocks['by_type'][$block->getType()] : false;
        }

        if (!$cacheServiceId) {
            // no context cache needed
            return;
        }

        // do not add cache settings to extra_cache_keys
        unset($settings['use_cache'], $settings['extra_cache_keys'], $settings['ttl']);

        $extraCacheKeys = $blockContext->getSetting('extra_cache_keys');

        // add context settings to extra_cache_keys
        if (!isset($extraCacheKeys[self::CACHE_KEY])) {
            $extraCacheKeys[self::CACHE_KEY] = $settings;
            $blockContext->setSetting('extra_cache_keys', $extraCacheKeys);
        }
    }
protected function setDefaultExtraCacheKeys ( BlockContextInterface $ blockContext , array $ settings ) { if ( ! $ blockContext -> getSetting ( 'use_cache' ) || $ blockContext -> getSetting ( 'ttl' ) <= 0 ) { return ; } $ block = $ blockContext -> getBlock ( ) ; // type by block class $ class = ClassUtils :: getClass ( $ block ) ; $ cacheServiceId = isset ( $ this -> cacheBlocks [ 'by_class' ] [ $ class ] ) ? $ this -> cacheBlocks [ 'by_class' ] [ $ class ] : false ; // type by block service if ( ! $ cacheServiceId ) { $ cacheServiceId = isset ( $ this -> cacheBlocks [ 'by_type' ] [ $ block -> getType ( ) ] ) ? $ this -> cacheBlocks [ 'by_type' ] [ $ block -> getType ( ) ] : false ; } if ( ! $ cacheServiceId ) { // no context cache needed return ; } // do not add cache settings to extra_cache_keys unset ( $ settings [ 'use_cache' ] , $ settings [ 'extra_cache_keys' ] , $ settings [ 'ttl' ] ) ; $ extraCacheKeys = $ blockContext -> getSetting ( 'extra_cache_keys' ) ; // add context settings to extra_cache_keys if ( ! isset ( $ extraCacheKeys [ self :: CACHE_KEY ] ) ) { $ extraCacheKeys [ self :: CACHE_KEY ] = $ settings ; $ blockContext -> setSetting ( 'extra_cache_keys' , $ extraCacheKeys ) ; } }
Adds context settings, to be able to rebuild a block context, to the
extra_cache_keys.

@param BlockContextInterface $blockContext
@param array                 $settings
Adds context settings to be able to rebuild a block context to the extra_cache_keys .