You are here

protected static function Facet::clearBlockCache in Facets 8

Clear the block cache.

This includes resetting the shared plugin block manager as this can result in the block definition cache being rebuilt in the same request with stale static caches in the deriver.

2 calls to Facet::clearBlockCache()
Facet::postDelete in src/Entity/Facet.php
Acts on deleted entities before the delete hook is invoked.
Facet::postSave in src/Entity/Facet.php
Acts on a saved entity before the insert or update hook is invoked.

File

src/Entity/Facet.php, line 1012

Class

Facet
Defines the facet configuration entity.

Namespace

Drupal\facets\Entity

Code

protected static function clearBlockCache() {
  $container = \Drupal::getContainer();

  // If the block manager has already been loaded, we may have stale static
  // caches in the facet deriver, so lets clear it out.
  $container
    ->set('plugin.manager.block', NULL);

  // Now rebuild the cache to force a fresh set of data.
  $container
    ->get('plugin.manager.block')
    ->clearCachedDefinitions();
}