diff --git a/Content/ArticleResourceItem.php b/Content/ArticleResourceItem.php index 5e73201bf..7c6f36b2b 100644 --- a/Content/ArticleResourceItem.php +++ b/Content/ArticleResourceItem.php @@ -110,6 +110,22 @@ public function getPublished(): \DateTime return $this->article->getPublished(); } + /** + * Returns isUpdated. + */ + public function getIsUpdated(): bool + { + return $this->article->getIsUpdated(); + } + + /** + * Returns updated. + */ + public function getUpdated(): ?\DateTime + { + return $this->article->getUpdated(); + } + /** * Returns authored. */ diff --git a/Document/ArticleDocument.php b/Document/ArticleDocument.php index f558216e8..da721c9c5 100644 --- a/Document/ArticleDocument.php +++ b/Document/ArticleDocument.php @@ -147,6 +147,16 @@ class ArticleDocument implements UuidBehavior, */ protected $changed; + /** + * @var bool + */ + protected $isUpdated; + + /** + * @var \DateTime|null + */ + protected $updated; + /** * @var int */ @@ -427,6 +437,26 @@ public function getAuthored() return $this->authored; } + public function setIsUpdated($isUpdated) + { + $this->isUpdated = $isUpdated; + } + + public function getIsUpdated() + { + return $this->isUpdated; + } + + public function setUpdated($updated) + { + $this->updated = $updated; + } + + public function getUpdated() + { + return $this->updated; + } + public function setAuthored($authored) { $this->authored = $authored; diff --git a/Document/ArticleViewDocument.php b/Document/ArticleViewDocument.php index dd77e24fd..4dce7bffd 100644 --- a/Document/ArticleViewDocument.php +++ b/Document/ArticleViewDocument.php @@ -168,6 +168,20 @@ class ArticleViewDocument implements ArticleViewDocumentInterface */ protected $seo; + /** + * @var bool + * + * @Property(type="boolean") + */ + protected $isUpdated; + + /** + * @var \DateTime|null + * + * @Property(type="date") + */ + protected $updated; + /** * @var \DateTime * @@ -484,6 +498,38 @@ public function setSeo(SeoViewObject $seo) return $this; } + public function getIsUpdated() + { + return $this->isUpdated; + } + + public function setIsUpdated($isUpdated) + { + $this->isUpdated = $isUpdated; + + return $this; + } + + /** + * @return \DateTime|null + */ + public function getUpdated() + { + return $this->updated; + } + + /** + * @param \DateTime|null $updated + * + * @return $this|ArticleViewDocument + */ + public function setUpdated($updated) + { + $this->updated = $updated; + + return $this; + } + public function getAuthored() { return $this->authored; diff --git a/Document/ArticleViewDocumentInterface.php b/Document/ArticleViewDocumentInterface.php index ba73cfcbe..78e3f09cd 100644 --- a/Document/ArticleViewDocumentInterface.php +++ b/Document/ArticleViewDocumentInterface.php @@ -257,6 +257,38 @@ public function getSeo(); */ public function setSeo(SeoViewObject $seo); + /** + * Returns isUpdated. + * + * @return bool + */ + public function getIsUpdated(); + + /** + * Set updated date. + * + * @param bool $isUpdated + * + * @return $this + */ + public function setIsUpdated($isUpdated); + + /** + * Returns updated. + * + * @return \DateTime|null + */ + public function getUpdated(); + + /** + * Set updated date. + * + * @param \DateTime|null $updated + * + * @return $this + */ + public function setUpdated($updated); + /** * Returns authored. * diff --git a/Document/Form/ArticleDocumentType.php b/Document/Form/ArticleDocumentType.php index 56cea89ae..119f0d629 100644 --- a/Document/Form/ArticleDocumentType.php +++ b/Document/Form/ArticleDocumentType.php @@ -46,6 +46,14 @@ public function buildForm(FormBuilderInterface $builder, array $options) ] ); + $builder->add('isUpdated', CheckboxType::class); + $builder->add( + 'updated', + DateTimeType::class, + [ + 'widget' => 'single_text', + ] + ); $builder->add('author', TextType::class); $builder->add( 'authored', diff --git a/Document/Index/ArticleIndexer.php b/Document/Index/ArticleIndexer.php index 2fd4eecf2..0221e667a 100644 --- a/Document/Index/ArticleIndexer.php +++ b/Document/Index/ArticleIndexer.php @@ -186,6 +186,8 @@ protected function createOrUpdateArticle( $this->setParentPageUuid($document, $article); $article->setChanged($document->getChanged()); $article->setCreated($document->getCreated()); + $article->setIsUpdated($document->getIsUpdated()); + $article->setUpdated($document->getUpdated()); $article->setAuthored($document->getAuthored()); if ($document->getAuthor() && $author = $this->contactRepository->find($document->getAuthor())) { $article->setAuthorId($author->getId()); diff --git a/Resources/config/forms/article_settings.xml b/Resources/config/forms/article_settings.xml index f425626c9..7995bb4d5 100644 --- a/Resources/config/forms/article_settings.xml +++ b/Resources/config/forms/article_settings.xml @@ -107,6 +107,21 @@ sulu_page.editing_information + + + sulu_page.is_updated + + + + + + + + + + sulu_page.updated_date + + sulu_page.authored_date diff --git a/Resources/config/serializer/Document.ArticleDocument.xml b/Resources/config/serializer/Document.ArticleDocument.xml index 9bee90b7d..39154c0b4 100644 --- a/Resources/config/serializer/Document.ArticleDocument.xml +++ b/Resources/config/serializer/Document.ArticleDocument.xml @@ -25,6 +25,8 @@ + + diff --git a/Resources/config/serializer/Document.ArticleViewDocument.xml b/Resources/config/serializer/Document.ArticleViewDocument.xml index dc14198cd..bde7d31e1 100644 --- a/Resources/config/serializer/Document.ArticleViewDocument.xml +++ b/Resources/config/serializer/Document.ArticleViewDocument.xml @@ -9,6 +9,8 @@ + + diff --git a/Trash/ArticleTrashItemHandler.php b/Trash/ArticleTrashItemHandler.php index b47eb68ec..fb67e2f96 100644 --- a/Trash/ArticleTrashItemHandler.php +++ b/Trash/ArticleTrashItemHandler.php @@ -100,12 +100,15 @@ public function store(object $article, array $options = []): TrashItemInterface $structureData[RoutableSubscriber::ROUTE_FIELD] = $localizedArticle->getRoutePath(); $articleTitles[$locale] = $localizedArticle->getTitle(); + $updated = $localizedArticle->getUpdated() ? $localizedArticle->getUpdated()->format('c') : null; $data['locales'][] = [ 'title' => $localizedArticle->getTitle(), 'locale' => $locale, 'creator' => $localizedArticle->getCreator(), 'created' => $localizedArticle->getCreated()->format('c'), + 'isUpdated' => $localizedArticle->getIsUpdated(), + 'updated' => $updated, 'author' => $localizedArticle->getAuthor(), 'authored' => $localizedArticle->getAuthored()->format('c'), 'structureType' => $localizedArticle->getStructureType(), @@ -159,11 +162,14 @@ public function restore(TrashItemInterface $trashItem, array $restoreFormData = $localizedArticle->setParent($this->documentManager->find($data['parentUuid'])); $localizedArticle->setUuid($uuid); } + $updated = $localeData['updated'] ? new \DateTime($localeData['updated']) : null; $localizedArticle->setTitle($localeData['title']); $localizedArticle->setLocale($locale); $localizedArticle->setCreator($localeData['creator']); $localizedArticle->setCreated(new \DateTime($localeData['created'])); + $localizedArticle->setIsUpdated($localeData['isUpdated']); + $localizedArticle->setUpdated($updated); $localizedArticle->setAuthor($localeData['author']); $localizedArticle->setAuthored(new \DateTime($localeData['authored'])); $localizedArticle->setStructureType($localeData['structureType']);