vendor/ezsystems/ezpublish-kernel/eZ/Bundle/EzPublishCoreBundle/ApiLoader/CacheFactory.php line 32

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) eZ Systems AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. namespace eZ\Bundle\EzPublishCoreBundle\ApiLoader;
  7. use eZ\Publish\Core\MVC\ConfigResolverInterface;
  8. use Symfony\Component\Cache\Adapter\TagAwareAdapter;
  9. use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
  10. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  11. use Symfony\Component\DependencyInjection\ContainerAwareTrait;
  12. /**
  13.  * Class CacheFactory.
  14.  *
  15.  * Service "ezpublish.cache_pool", selects a Symfony cache service based on siteaccess[-group] setting "cache_service_name"
  16.  */
  17. class CacheFactory implements ContainerAwareInterface
  18. {
  19.     use ContainerAwareTrait;
  20.     /**
  21.      * @param ConfigResolverInterface $configResolver
  22.      *
  23.      * @return \Symfony\Component\Cache\Adapter\TagAwareAdapterInterface
  24.      */
  25.     public function getCachePool(ConfigResolverInterface $configResolver)
  26.     {
  27.         /** @var \Symfony\Component\Cache\Adapter\AdapterInterface $cacheService */
  28.         $cacheService $this->container->get($configResolver->getParameter('cache_service_name'));
  29.         // If cache service is already implementing TagAwareAdapterInterface, return as-is
  30.         if ($cacheService instanceof TagAwareAdapterInterface) {
  31.             return $cacheService;
  32.         }
  33.         return new TagAwareAdapter(
  34.             $cacheService
  35.         );
  36.     }
  37. }