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

  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.     /**
  14.      * @internal
  15.      */
  16.     public function __construct(private readonly SystemConfigService $config, private readonly AbstractTranslator $translator, private readonly CacheTagCollection $collection)
  17.     {
  18.     }
  19.     public function getDecorated(): AbstractCacheTracer
  20.     {
  21.         throw new DecorationPatternException(self::class);
  22.     }
  23.     /**
  24.      * @return mixed|null All kind of data could be cached
  25.      */
  26.     public function trace(string $key\Closure $param)
  27.     {
  28.         return $this->collection->trace($key, fn () => $this->translator->trace($key, fn () => $this->config->trace($key$param)));
  29.     }
  30.     public function get(string $key): array
  31.     {
  32.         return array_merge(
  33.             $this->collection->getTrace($key),
  34.             $this->config->getTrace($key),
  35.             $this->translator->getTrace($key)
  36.         );
  37.     }
  38. }