diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 6c16f9b0..6db92ac7 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -137,7 +137,7 @@ jobs: coverage: none - name: Remove not required tooling - run: composer remove php-cs-fixer/shim --dev --no-interaction --no-update + run: composer remove php-cs-fixer/shim "*phpstan*" --dev --no-interaction --no-update - name: Require elasticsearch dependency run: composer require --dev elasticsearch/elasticsearch:"${{ matrix.elasticsearch-package-constraint }}" --no-interaction --no-update diff --git a/Document/ArticleViewDocument.php b/Document/ArticleViewDocument.php index a211a9a3..7ef96af3 100644 --- a/Document/ArticleViewDocument.php +++ b/Document/ArticleViewDocument.php @@ -498,22 +498,15 @@ public function setSeo(SeoViewObject $seo) return $this; } - /** - * @return \DateTime|null - */ public function getLastModified() { return $this->lastModified; } - /** - * @param \DateTime|null $lastModified - * - * @return $this|ArticleViewDocument - */ public function setLastModified($lastModified) { $this->lastModified = $lastModified; + $this->updateLastModifiedOrAuthored(); return $this; } @@ -524,11 +517,20 @@ public function getLastModifiedOrAuthored(): \DateTime } /** - * @param \DateTime|null $lastModified + * @internal Setter is required for ONGR but should not be used. + * + * @param \DateTime $lastModifiedOrAuthored * - * @return $this|ArticleViewDocument + * @return static */ - public function setLastModifiedOrAuthored() + public function setLastModifiedOrAuthored(\DateTime $lastModifiedOrAuthored) + { + $this->lastModifiedOrAuthored = $lastModifiedOrAuthored; + + return $this; + } + + public function updateLastModifiedOrAuthored() { $this->lastModifiedOrAuthored = $this->lastModified ?? $this->authored; @@ -543,6 +545,7 @@ public function getAuthored() public function setAuthored(?\DateTime $authored = null) { $this->authored = $authored; + $this->updateLastModifiedOrAuthored(); return $this; } diff --git a/Document/ArticleViewDocumentInterface.php b/Document/ArticleViewDocumentInterface.php index db28604e..21df42a9 100644 --- a/Document/ArticleViewDocumentInterface.php +++ b/Document/ArticleViewDocumentInterface.php @@ -294,7 +294,10 @@ public function setAuthored(?\DateTime $authored = null); */ public function getLastModifiedOrAuthored(); - public function setLastModifiedOrAuthored(); + /** + * @return $this + */ + public function updateLastModifiedOrAuthored(); /** * Returns author full name. diff --git a/Document/LocalizedLastModifiedBehavior.php b/Document/LocalizedLastModifiedBehavior.php new file mode 100644 index 00000000..fc55cfb7 --- /dev/null +++ b/Document/LocalizedLastModifiedBehavior.php @@ -0,0 +1,30 @@ +setPublic(true); } + /** + * @return array + */ protected function getKernelParameters(): array { $parameters = parent::getKernelParameters(); diff --git a/Trash/ArticleTrashItemHandler.php b/Trash/ArticleTrashItemHandler.php index 53a22339..23a9bf09 100644 --- a/Trash/ArticleTrashItemHandler.php +++ b/Trash/ArticleTrashItemHandler.php @@ -176,7 +176,7 @@ public function restore(TrashItemInterface $trashItem, array $restoreFormData = $localizedArticle->setParent($this->documentManager->find($data['parentUuid'])); $localizedArticle->setUuid($uuid); } - $lastModified = array_key_exists('lastModified', $localeData) && $localeData['lastModified'] ? new \DateTime($localeData['lastModified']) : null; + $lastModified = \array_key_exists('lastModified', $localeData) && $localeData['lastModified'] ? new \DateTime($localeData['lastModified']) : null; $localizedArticle->setTitle($localeData['title']); $localizedArticle->setLocale($locale);