3 namespace Drupal\Core\Cache;
5 use Symfony\Component\DependencyInjection\ContainerBuilder;
6 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9 * Adds cache_bins parameter to the container.
11 class ListCacheBinsPass implements CompilerPassInterface {
14 * Implements CompilerPassInterface::process().
16 * Collects the cache bins into the cache_bins parameter.
18 public function process(ContainerBuilder $container) {
20 $cache_default_bin_backends = [];
21 foreach ($container->findTaggedServiceIds('cache.bin') as $id => $attributes) {
22 $bin = substr($id, strpos($id, '.') + 1);
23 $cache_bins[$id] = $bin;
24 if (isset($attributes[0]['default_backend'])) {
25 $cache_default_bin_backends[$bin] = $attributes[0]['default_backend'];
28 $container->setParameter('cache_bins', $cache_bins);
29 $container->setParameter('cache_default_bin_backends', $cache_default_bin_backends);