vendor/shopware/core/System/SystemConfig/CachedSystemConfigLoader.php line 37

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\System\SystemConfig;
  3. use Shopware\Core\Framework\Adapter\Cache\CacheValueCompressor;
  4. use Shopware\Core\Framework\Log\Package;
  5. use Symfony\Contracts\Cache\CacheInterface;
  6. use Symfony\Contracts\Cache\ItemInterface;
  7. #[Package('system-settings')]
  8. class CachedSystemConfigLoader extends AbstractSystemConfigLoader
  9. {
  10.     final public const CACHE_TAG 'system-config';
  11.     /**
  12.      * @internal
  13.      */
  14.     public function __construct(private readonly AbstractSystemConfigLoader $decorated, private readonly CacheInterface $cache)
  15.     {
  16.     }
  17.     public function getDecorated(): AbstractSystemConfigLoader
  18.     {
  19.         return $this->decorated;
  20.     }
  21.     public function load(?string $salesChannelId): array
  22.     {
  23.         $key 'system-config-' $salesChannelId;
  24.         $value $this->cache->get($key, function (ItemInterface $item) use ($salesChannelId) {
  25.             $config $this->getDecorated()->load($salesChannelId);
  26.             $item->tag([self::CACHE_TAG]);
  27.             return CacheValueCompressor::compress($config);
  28.         });
  29.         return CacheValueCompressor::uncompress($value);
  30.     }
  31. }