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

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