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