You are here

class ListCacheBinsPass in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Cache/ListCacheBinsPass.php \Drupal\Core\Cache\ListCacheBinsPass

Adds cache_bins parameter to the container.

Hierarchy

  • class \Drupal\Core\Cache\ListCacheBinsPass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface

Expanded class hierarchy of ListCacheBinsPass

1 file declares its use of ListCacheBinsPass
CoreServiceProvider.php in core/lib/Drupal/Core/CoreServiceProvider.php

File

core/lib/Drupal/Core/Cache/ListCacheBinsPass.php, line 11

Namespace

Drupal\Core\Cache
View source
class ListCacheBinsPass implements CompilerPassInterface {

  /**
   * Implements CompilerPassInterface::process().
   *
   * Collects the cache bins into the cache_bins parameter.
   */
  public function process(ContainerBuilder $container) {
    $cache_bins = [];
    $cache_default_bin_backends = [];
    foreach ($container
      ->findTaggedServiceIds('cache.bin') as $id => $attributes) {
      $bin = substr($id, strpos($id, '.') + 1);
      $cache_bins[$id] = $bin;
      if (isset($attributes[0]['default_backend'])) {
        $cache_default_bin_backends[$bin] = $attributes[0]['default_backend'];
      }
    }
    $container
      ->setParameter('cache_bins', $cache_bins);
    $container
      ->setParameter('cache_default_bin_backends', $cache_default_bin_backends);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ListCacheBinsPass::process public function Implements CompilerPassInterface::process().