"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/lib/Drupal/Core/Cache/ListCacheBinsPass.php" (26 Nov 2020, 994 Bytes) of package /linux/www/drupal-8.9.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ListCacheBinsPass.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\Core\Cache;
    4 
    5 use Symfony\Component\DependencyInjection\ContainerBuilder;
    6 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
    7 
    8 /**
    9  * Adds cache_bins parameter to the container.
   10  */
   11 class ListCacheBinsPass implements CompilerPassInterface {
   12 
   13   /**
   14    * Implements CompilerPassInterface::process().
   15    *
   16    * Collects the cache bins into the cache_bins parameter.
   17    */
   18   public function process(ContainerBuilder $container) {
   19     $cache_bins = [];
   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'];
   26       }
   27     }
   28     $container->setParameter('cache_bins', $cache_bins);
   29     $container->setParameter('cache_default_bin_backends', $cache_default_bin_backends);
   30   }
   31 
   32 }