ExtraFieldBlockCacheTagInvalidator.php

Same filename and directory in other branches
  1. 10 core/modules/layout_builder/src/Cache/ExtraFieldBlockCacheTagInvalidator.php

Namespace

Drupal\layout_builder\Cache

File

core/modules/layout_builder/src/Cache/ExtraFieldBlockCacheTagInvalidator.php

View source
<?php

namespace Drupal\layout_builder\Cache;

use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
use Drupal\Core\Block\BlockManagerInterface;
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;

/**
 * Provides a cache tag invalidator that clears the block cache.
 *
 * @internal
 *   Tagged services are internal.
 */
class ExtraFieldBlockCacheTagInvalidator implements CacheTagsInvalidatorInterface {
    
    /**
     * Constructs a new ExtraFieldBlockCacheTagInvalidator.
     *
     * @param \Drupal\Core\Block\BlockManagerInterface $blockManager
     *   The block manager.
     */
    public function __construct(BlockManagerInterface $blockManager) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function invalidateTags(array $tags) {
        if (in_array('entity_field_info', $tags, TRUE)) {
            if ($this->blockManager instanceof CachedDiscoveryInterface) {
                $this->blockManager
                    ->clearCachedDefinitions();
            }
        }
    }

}

Classes

Title Deprecated Summary
ExtraFieldBlockCacheTagInvalidator Provides a cache tag invalidator that clears the block cache.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.