function ListCacheBinsPass::process

Same name in other branches
  1. 9 core/lib/Drupal/Core/Cache/ListCacheBinsPass.php \Drupal\Core\Cache\ListCacheBinsPass::process()
  2. 10 core/lib/Drupal/Core/Cache/ListCacheBinsPass.php \Drupal\Core\Cache\ListCacheBinsPass::process()
  3. 11.x core/lib/Drupal/Core/Cache/ListCacheBinsPass.php \Drupal\Core\Cache\ListCacheBinsPass::process()

Implements CompilerPassInterface::process().

Collects the cache bins into the cache_bins parameter.

File

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

Class

ListCacheBinsPass
Adds cache_bins parameter to the container.

Namespace

Drupal\Core\Cache

Code

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);
}

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