diff --git a/lib/RoadizCoreBundle/src/Api/DataTransformer/WebResponseOutputDataTransformer.php b/lib/RoadizCoreBundle/src/Api/DataTransformer/WebResponseOutputDataTransformer.php index 5c7c2a69..d4d46109 100644 --- a/lib/RoadizCoreBundle/src/Api/DataTransformer/WebResponseOutputDataTransformer.php +++ b/lib/RoadizCoreBundle/src/Api/DataTransformer/WebResponseOutputDataTransformer.php @@ -93,6 +93,7 @@ public function transform(PersistableInterface $object, string $to, array $conte ], UrlGeneratorInterface::ABSOLUTE_PATH)); $output->setHead($this->nodesSourcesHeadFactory->createForNodeSource($object)); $output->setBreadcrumbs($this->breadcrumbsFactory->create($object)); + $output->setMaxAge($object->getNode()->getTtl() * 60); } if ($object instanceof TranslationInterface) { $output->setHead($this->nodesSourcesHeadFactory->createForTranslation($object)); diff --git a/lib/RoadizCoreBundle/src/Api/Model/WebResponseInterface.php b/lib/RoadizCoreBundle/src/Api/Model/WebResponseInterface.php index b295c30f..8a43399b 100644 --- a/lib/RoadizCoreBundle/src/Api/Model/WebResponseInterface.php +++ b/lib/RoadizCoreBundle/src/Api/Model/WebResponseInterface.php @@ -14,4 +14,6 @@ public function setBreadcrumbs(?BreadcrumbsInterface $breadcrumbs): self; public function setItem(?PersistableInterface $item): self; public function setPath(?string $path): self; public function getItem(): ?PersistableInterface; + public function getMaxAge(): ?int; + public function setMaxAge(?int $maxAge): self; } diff --git a/lib/RoadizCoreBundle/src/Api/Model/WebResponseTrait.php b/lib/RoadizCoreBundle/src/Api/Model/WebResponseTrait.php index da99f808..141afde7 100644 --- a/lib/RoadizCoreBundle/src/Api/Model/WebResponseTrait.php +++ b/lib/RoadizCoreBundle/src/Api/Model/WebResponseTrait.php @@ -39,6 +39,23 @@ trait WebResponseTrait #[Serializer\Groups(["web_response"])] private bool $hidingBlocks = false; + /** + * @var int|null WebResponse item maximum age in seconds + */ + #[Serializer\Groups(["web_response"])] + private ?int $maxAge = null; + + public function getMaxAge(): ?int + { + return $this->maxAge; + } + + public function setMaxAge(?int $maxAge): self + { + $this->maxAge = $maxAge; + return $this; + } + public function setPath(?string $path): self { $this->path = $path;