vendor/shopware/core/Framework/Adapter/Cache/CacheTracer.php line 43

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Adapter\Cache;
  3. use Shopware\Core\Framework\Adapter\Translation\AbstractTranslator;
  4. use Shopware\Core\Framework\Log\Package;
  5. use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
  6. use Shopware\Core\System\SystemConfig\SystemConfigService;
  7. /**
  8.  * @extends AbstractCacheTracer<mixed|null>
  9.  */
  10. #[Package('core')]
  11. class CacheTracer extends AbstractCacheTracer
  12. {
  13.     private SystemConfigService $config;
  14.     private AbstractTranslator $translator;
  15.     private CacheTagCollection $collection;
  16.     /**
  17.      * @internal
  18.      */
  19.     public function __construct(SystemConfigService $configAbstractTranslator $translatorCacheTagCollection $collection)
  20.     {
  21.         $this->config $config;
  22.         $this->translator $translator;
  23.         $this->collection $collection;
  24.     }
  25.     public function getDecorated(): AbstractCacheTracer
  26.     {
  27.         throw new DecorationPatternException(self::class);
  28.     }
  29.     /**
  30.      * @return mixed|null All kind of data could be cached
  31.      */
  32.     public function trace(string $key, \Closure $param)
  33.     {
  34.         return $this->collection->trace($key, function () use ($key$param) {
  35.             return $this->translator->trace($key, function () use ($key$param) {
  36.                 return $this->config->trace($key$param);
  37.             });
  38.         });
  39.     }
  40.     public function get(string $key): array
  41.     {
  42.         return array_merge(
  43.             $this->collection->getTrace($key),
  44.             $this->config->getTrace($key),
  45.             $this->translator->getTrace($key)
  46.         );
  47.     }
  48. }