From 198fa927b793ccf0dac2185757e33c483732846c Mon Sep 17 00:00:00 2001 From: Luca Kredel Date: Sun, 26 May 2019 19:55:11 +0200 Subject: [PATCH] [BUGFIX] Set default doktype for post model (#83) Set the correct doktype via the post model. This is required when posts are created via Extbase, in an action or a command for example. Releases: master, 9.1, 9.0, 8.7, 7.6 Fixes: #82 --- Classes/Domain/Model/Post.php | 16 +++++++++++++++ Tests/Unit/Domain/Model/PostTest.php | 30 ++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 Tests/Unit/Domain/Model/PostTest.php diff --git a/Classes/Domain/Model/Post.php b/Classes/Domain/Model/Post.php index 7fe39a4a..b082e753 100644 --- a/Classes/Domain/Model/Post.php +++ b/Classes/Domain/Model/Post.php @@ -10,6 +10,7 @@ namespace T3G\AgencyPack\Blog\Domain\Model; +use T3G\AgencyPack\Blog\Constants; use T3G\AgencyPack\Blog\Domain\Repository\CommentRepository; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Annotation as Extbase; @@ -20,6 +21,13 @@ class Post extends AbstractEntity { + /** + * The blog post doktype + * + * @var int + */ + protected $doktype = Constants::DOKTYPE_BLOG_POST; + /** * The blog post title. * @@ -145,6 +153,14 @@ public function initializeObject(): void $this->media = new ObjectStorage(); } + /** + * @return int + */ + public function getDoktype(): ?int + { + return $this->doktype; + } + /** * @param Author $author * @return Post diff --git a/Tests/Unit/Domain/Model/PostTest.php b/Tests/Unit/Domain/Model/PostTest.php new file mode 100644 index 00000000..bbc5b65d --- /dev/null +++ b/Tests/Unit/Domain/Model/PostTest.php @@ -0,0 +1,30 @@ +getDoktype()); + } +}