vendor/shopware/storefront/Framework/Cache/Annotation/HttpCache.php line 11

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Storefront\Framework\Cache\Annotation;
  3. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation;
  4. use Shopware\Core\Framework\Script\Api\ResponseCacheConfiguration;
  5. /**
  6.  * @Annotation
  7.  */
  8. class HttpCache extends ConfigurationAnnotation
  9. {
  10.     public const ALIAS 'httpCache';
  11.     private ?int $maxAge null;
  12.     private ?array $states null;
  13.     /**
  14.      * @return string
  15.      */
  16.     public function getAliasName()
  17.     {
  18.         return self::ALIAS;
  19.     }
  20.     /**
  21.      * @return bool
  22.      */
  23.     public function allowArray()
  24.     {
  25.         return true;
  26.     }
  27.     public function getMaxAge(): ?int
  28.     {
  29.         return $this->maxAge;
  30.     }
  31.     public function setMaxAge(?int $maxAge): void
  32.     {
  33.         $this->maxAge $maxAge;
  34.     }
  35.     public function getStates(): array
  36.     {
  37.         return $this->states ?? [];
  38.     }
  39.     public function setStates(?array $states): void
  40.     {
  41.         $this->states $states;
  42.     }
  43.     /**
  44.      * @internal only for use by the app system
  45.      */
  46.     public static function fromScriptResponseCacheConfig(ResponseCacheConfiguration $configuration): self
  47.     {
  48.         return new self([
  49.             'states' => $configuration->getInvalidationStates(),
  50.             'maxAge' => $configuration->getMaxAge(),
  51.         ]);
  52.     }
  53. }