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

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Adapter\Cache;
  3. class CacheTagCollection
  4. {
  5.     private array $keys = ['all' => true];
  6.     private array $traces = [];
  7.     public function reset(): void
  8.     {
  9.         $this->traces = [];
  10.         $this->keys = ['all' => true];
  11.     }
  12.     /**
  13.      * @param string|array $tags
  14.      */
  15.     public function add($tags): void
  16.     {
  17.         foreach (array_keys($this->keys) as $trace) {
  18.             if (\is_string($tags)) {
  19.                 $this->traces[$trace][$tags] = true;
  20.             }
  21.             if (\is_array($tags)) {
  22.                 foreach ($tags as $tag) {
  23.                     $this->traces[$trace][$tag] = true;
  24.                 }
  25.             }
  26.         }
  27.     }
  28.     /**
  29.      * @return mixed|null All kind of data could be cached
  30.      */
  31.     public function trace(string $key\Closure $param)
  32.     {
  33.         $this->traces[$key] = [];
  34.         $this->keys[$key] = true;
  35.         $result $param();
  36.         unset($this->keys[$key]);
  37.         return $result;
  38.     }
  39.     public function getTrace(string $key): array
  40.     {
  41.         $trace = isset($this->traces[$key]) ? array_keys($this->traces[$key]) : [];
  42.         unset($this->traces[$key]);
  43.         return $trace;
  44.     }
  45. }