Skip to content

Commit

Permalink
Merge tag v2.2.14 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Mar 20, 2024
1 parent 8fd9efd commit 8cf5631
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Extension/ArchiveExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function getResult(

foreach ($paginator as $result) {
$dateTimeField = reset($result);
if ($dateTimeField instanceof \DateTime) {
if ($dateTimeField instanceof \DateTimeInterface) {
$year = $dateTimeField->format('Y');
$month = $dateTimeField->format('Y-m');

Expand Down
2 changes: 2 additions & 0 deletions src/Api/Model/WebResponseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
17 changes: 17 additions & 0 deletions src/Api/Model/WebResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/NodesDetailsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (is_array($data)) {
$data = implode(', ', $data);
}
if ($data instanceof \DateTime) {
if ($data instanceof \DateTimeInterface) {
$data = $data->format('c');
}
if ($data instanceof \stdClass) {
Expand Down
2 changes: 1 addition & 1 deletion src/CustomForm/CustomFormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ protected function getDocumentFolderForCustomForm(): ?Folder
*/
private function formValueToString($rawValue): string
{
if ($rawValue instanceof \DateTime) {
if ($rawValue instanceof \DateTimeInterface) {
return $rawValue->format('Y-m-d H:i:s');
} elseif (is_array($rawValue)) {
$values = $rawValue;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/AttributeValueTranslationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function setValue(mixed $value)
return $this;
case AttributeInterface::DATETIME_T:
case AttributeInterface::DATE_T:
if ($value instanceof \DateTime) {
if ($value instanceof \DateTimeInterface) {
$this->value = $value->format('Y-m-d H:i:s');
} else {
$this->value = (string) $value;
Expand Down
10 changes: 5 additions & 5 deletions src/SearchEngine/NodeSourceSearchHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ protected function argFqProcess(array &$args): array
*/
if (isset($args['publishedAt'])) {
$tmp = "published_at_dt:";
if (!is_array($args['publishedAt']) && $args['publishedAt'] instanceof \DateTime) {
if (!is_array($args['publishedAt']) && $args['publishedAt'] instanceof \DateTimeInterface) {
$tmp .= $this->formatDateTimeToUTC($args['publishedAt']);
} elseif (
isset($args['publishedAt'][0]) &&
$args['publishedAt'][0] === "BETWEEN" &&
isset($args['publishedAt'][1]) &&
$args['publishedAt'][1] instanceof \DateTime &&
$args['publishedAt'][1] instanceof \DateTimeInterface &&
isset($args['publishedAt'][2]) &&
$args['publishedAt'][2] instanceof \DateTime
$args['publishedAt'][2] instanceof \DateTimeInterface
) {
$tmp .= "[" .
$this->formatDateTimeToUTC($args['publishedAt'][1]) .
Expand All @@ -186,14 +186,14 @@ protected function argFqProcess(array &$args): array
isset($args['publishedAt'][0]) &&
$args['publishedAt'][0] === "<=" &&
isset($args['publishedAt'][1]) &&
$args['publishedAt'][1] instanceof \DateTime
$args['publishedAt'][1] instanceof \DateTimeInterface
) {
$tmp .= "[* TO " . $this->formatDateTimeToUTC($args['publishedAt'][1]) . "]";
} elseif (
isset($args['publishedAt'][0]) &&
$args['publishedAt'][0] === ">=" &&
isset($args['publishedAt'][1]) &&
$args['publishedAt'][1] instanceof \DateTime
$args['publishedAt'][1] instanceof \DateTimeInterface
) {
$tmp .= "[" . $this->formatDateTimeToUTC($args['publishedAt'][1]) . " TO *]";
}
Expand Down
2 changes: 1 addition & 1 deletion src/Xlsx/XlsxExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function exportXlsx($data, $keys = [])
continue;
}

if ($value instanceof \DateTime) {
if ($value instanceof \DateTimeInterface) {
$value = Date::PHPToExcel($value);
$activeSheet->getStyle($columnAlpha . ($activeRow))
->getNumberFormat()
Expand Down

0 comments on commit 8cf5631

Please sign in to comment.