‪TYPO3CMS  10.4
Post.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 
27 {
31  protected ‪$blog;
32 
37  protected ‪$title = '';
38 
42  protected ‪$date;
43 
47  protected ‪$author;
48 
52  protected ‪$secondAuthor;
53 
57  protected ‪$reviewer;
58 
63  protected ‪$content = '';
64 
68  protected ‪$tags;
69 
73  protected ‪$categories;
74 
80  protected ‪$comments;
81 
86  protected ‪$relatedPosts;
87 
92  protected ‪$additionalName;
93 
98  protected ‪$additionalInfo;
99 
105  protected ‪$additionalComments;
106 
110  public function ‪__construct()
111  {
112  $this->tags = new ‪ObjectStorage();
113  $this->categories = new ‪ObjectStorage();
114  $this->comments = new ‪ObjectStorage();
115  $this->relatedPosts = new ‪ObjectStorage();
116  $this->date = new \DateTime();
117  $this->additionalComments = new ‪ObjectStorage();
118  }
119 
125  public function ‪setBlog(‪Blog ‪$blog)
126  {
127  $this->blog = ‪$blog;
128  }
129 
135  public function ‪getBlog()
136  {
137  return ‪$this->blog;
138  }
139 
145  public function ‪setTitle(‪$title)
146  {
147  $this->title = ‪$title;
148  }
149 
155  public function ‪getTitle()
156  {
157  return ‪$this->title;
158  }
159 
165  public function ‪setDate(\DateTime ‪$date)
166  {
167  $this->date = ‪$date;
168  }
169 
176  public function ‪getDate()
177  {
178  return ‪$this->date;
179  }
180 
186  public function ‪setTags(ObjectStorage ‪$tags)
187  {
188  $this->tags = ‪$tags;
189  }
190 
196  public function ‪addTag(Tag $tag)
197  {
198  $this->tags->attach($tag);
199  }
200 
206  public function ‪removeTag(‪Tag $tag)
207  {
208  $this->tags->detach($tag);
209  }
210 
214  public function ‪removeAllTags()
215  {
216  $this->tags = new ‪ObjectStorage();
217  }
218 
225  public function ‪getTags()
226  {
227  return clone ‪$this->tags;
228  }
229 
235  public function ‪addCategory(Category $category)
236  {
237  $this->categories->attach($category);
238  }
239 
245  public function ‪setCategories(‪$categories)
246  {
247  $this->categories = ‪$categories;
248  }
249 
255  public function ‪getCategories()
256  {
257  return ‪$this->categories;
258  }
259 
265  public function ‪removeCategory(Category $category)
266  {
267  $this->categories->detach($category);
268  }
269 
275  public function ‪setAuthor(Person ‪$author)
276  {
277  $this->author = ‪$author;
278  }
279 
285  public function ‪getAuthor()
286  {
288  }
289 
293  public function ‪getSecondAuthor(): ?‪Person
294  {
296  }
297 
301  public function ‪setSecondAuthor(‪Person ‪$secondAuthor): void
302  {
303  $this->secondAuthor = ‪$secondAuthor;
304  }
305 
309  public function ‪getReviewer()
310  {
311  return ‪$this->reviewer;
312  }
313 
317  public function ‪setReviewer(‪Person ‪$reviewer)
318  {
319  $this->reviewer = ‪$reviewer;
320  }
321 
327  public function ‪setContent(‪$content)
328  {
329  $this->content = ‪$content;
330  }
331 
337  public function ‪getContent()
338  {
339  return ‪$this->content;
340  }
341 
347  public function ‪setComments(ObjectStorage ‪$comments)
348  {
349  $this->comments = ‪$comments;
350  }
351 
357  public function ‪addComment(Comment $comment)
358  {
359  $this->comments->attach($comment);
360  }
361 
367  public function ‪removeComment(‪Comment $commentToDelete)
368  {
369  $this->comments->detach($commentToDelete);
370  }
371 
375  public function ‪removeAllComments()
376  {
378  $this->comments->removeAll(‪$comments);
379  }
380 
386  public function ‪getComments()
387  {
388  return ‪$this->comments;
389  }
390 
396  public function ‪setRelatedPosts(ObjectStorage ‪$relatedPosts)
397  {
398  $this->relatedPosts = ‪$relatedPosts;
399  }
400 
406  public function ‪addRelatedPost(‪Post $post)
407  {
408  $this->relatedPosts->attach($post);
409  }
410 
414  public function ‪removeAllRelatedPosts()
415  {
417  $this->relatedPosts->removeAll(‪$relatedPosts);
418  }
419 
425  public function ‪getRelatedPosts()
426  {
428  }
429 
433  public function ‪getAdditionalName(): ?‪Info
434  {
436  }
437 
441  public function ‪setAdditionalName(‪Info ‪$additionalName): void
442  {
443  $this->additionalName = ‪$additionalName;
444  }
445 
449  public function ‪getAdditionalInfo(): ?‪Info
450  {
452  }
453 
457  public function ‪setAdditionalInfo(‪Info ‪$additionalInfo): void
458  {
459  $this->additionalInfo = ‪$additionalInfo;
460  }
461 
465  public function ‪getAdditionalComments(): ‪ObjectStorage
466  {
468  }
469 
474  {
475  $this->additionalComments = ‪$additionalComments;
476  }
477 
481  public function ‪addAdditionalComment(‪Comment $comment)
482  {
483  $this->additionalComments->attach($comment);
484  }
485 
489  public function ‪removeAllAdditionalComments()
490  {
492  $this->additionalComments->removeAll(‪$comments);
493  }
494 
498  public function ‪removeAdditionalComment(‪Comment $comment)
499  {
500  $this->additionalComments->detach($comment);
501  }
502 
508  public function ‪__toString()
509  {
510  return $this->title . chr(10) .
511  ' written on ' . $this->date->format('Y-m-d') . chr(10) .
512  ' by ' . $this->author->getFullName() . chr(10) .
513  wordwrap($this->content, 70, chr(10)) . chr(10) .
514  implode(', ', $this->tags->toArray());
515  }
516 }
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getComments
‪TYPO3 CMS Extbase Persistence ObjectStorage getComments()
Definition: Post.php:372
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setComments
‪setComments(ObjectStorage $comments)
Definition: Post.php:333
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setAdditionalName
‪setAdditionalName(Info $additionalName)
Definition: Post.php:427
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setSecondAuthor
‪setSecondAuthor(Person $secondAuthor)
Definition: Post.php:287
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getBlog
‪ExtbaseTeam BlogExample Domain Model Blog getBlog()
Definition: Post.php:121
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:18
‪ExtbaseTeam\BlogExample\Domain\Model\Post\addAdditionalComment
‪addAdditionalComment(Comment $comment)
Definition: Post.php:467
‪ExtbaseTeam\BlogExample\Domain\Model\Post\removeComment
‪removeComment(Comment $commentToDelete)
Definition: Post.php:353
‪ExtbaseTeam\BlogExample\Domain\Model\Post\addComment
‪addComment(Comment $comment)
Definition: Post.php:343
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$title
‪string $title
Definition: Post.php:35
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$additionalComments
‪TYPO3 CMS Extbase Persistence ObjectStorage<\ExtbaseTeam\BlogExample\Domain\Model\Comment > $additionalComments
Definition: Post.php:91
‪ExtbaseTeam\BlogExample\Domain\Model\Post\removeCategory
‪removeCategory(Category $category)
Definition: Post.php:251
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$content
‪string $content
Definition: Post.php:56
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getRelatedPosts
‪TYPO3 CMS Extbase Persistence ObjectStorage getRelatedPosts()
Definition: Post.php:411
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$date
‪DateTime $date
Definition: Post.php:39
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setTitle
‪setTitle($title)
Definition: Post.php:131
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$categories
‪TYPO3 CMS Extbase Persistence ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category > $categories
Definition: Post.php:64
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$relatedPosts
‪TYPO3 CMS Extbase Persistence ObjectStorage<\ExtbaseTeam\BlogExample\Domain\Model\Post > $relatedPosts
Definition: Post.php:75
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getReviewer
‪ExtbaseTeam BlogExample Domain Model Person getReviewer()
Definition: Post.php:295
‪ExtbaseTeam\BlogExample\Domain\Model\Info
Definition: Info.php:24
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getTitle
‪string getTitle()
Definition: Post.php:141
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getContent
‪string getContent()
Definition: Post.php:323
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setRelatedPosts
‪setRelatedPosts(ObjectStorage $relatedPosts)
Definition: Post.php:382
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$secondAuthor
‪ExtbaseTeam BlogExample Domain Model Person $secondAuthor
Definition: Post.php:47
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$additionalInfo
‪ExtbaseTeam BlogExample Domain Model Info $additionalInfo
Definition: Post.php:85
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setAuthor
‪setAuthor(Person $author)
Definition: Post.php:261
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setAdditionalInfo
‪setAdditionalInfo(Info $additionalInfo)
Definition: Post.php:443
‪TYPO3\CMS\Extbase\DomainObject\AbstractEntity
Definition: AbstractEntity.php:23
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setDate
‪setDate(\DateTime $date)
Definition: Post.php:151
‪ExtbaseTeam\BlogExample\Domain\Model\Post\removeAllAdditionalComments
‪removeAllAdditionalComments()
Definition: Post.php:475
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getAdditionalName
‪Info getAdditionalName()
Definition: Post.php:419
‪TYPO3\CMS\Extbase\Persistence\ObjectStorage
Definition: ObjectStorage.php:28
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getSecondAuthor
‪ExtbaseTeam BlogExample Domain Model Person getSecondAuthor()
Definition: Post.php:279
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getCategories
‪TYPO3 CMS Extbase Persistence ObjectStorage getCategories()
Definition: Post.php:241
‪ExtbaseTeam\BlogExample\Domain\Model\Post\removeAdditionalComment
‪removeAdditionalComment(Comment $comment)
Definition: Post.php:484
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setReviewer
‪setReviewer(Person $reviewer)
Definition: Post.php:303
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setTags
‪setTags(ObjectStorage $tags)
Definition: Post.php:172
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setBlog
‪setBlog(Blog $blog)
Definition: Post.php:111
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getTags
‪TYPO3 CMS Extbase Persistence ObjectStorage getTags()
Definition: Post.php:211
‪ExtbaseTeam\BlogExample\Domain\Model\Post\addRelatedPost
‪addRelatedPost(Post $post)
Definition: Post.php:392
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getAdditionalInfo
‪Info getAdditionalInfo()
Definition: Post.php:435
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$blog
‪ExtbaseTeam BlogExample Domain Model Blog $blog
Definition: Post.php:30
‪ExtbaseTeam\BlogExample\Domain\Model\Post\__construct
‪__construct()
Definition: Post.php:96
‪ExtbaseTeam\BlogExample\Domain\Model\Blog
Definition: Blog.php:27
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$tags
‪TYPO3 CMS Extbase Persistence ObjectStorage<\ExtbaseTeam\BlogExample\Domain\Model\Tag > $tags
Definition: Post.php:60
‪ExtbaseTeam\BlogExample\Domain\Model\Post
Definition: Post.php:27
‪ExtbaseTeam\BlogExample\Domain\Model\Comment
Definition: Comment.php:25
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getDate
‪DateTime getDate()
Definition: Post.php:162
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setContent
‪setContent($content)
Definition: Post.php:313
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getAuthor
‪ExtbaseTeam BlogExample Domain Model Person getAuthor()
Definition: Post.php:271
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$reviewer
‪ExtbaseTeam BlogExample Domain Model Person $reviewer
Definition: Post.php:51
‪ExtbaseTeam\BlogExample\Domain\Model\Post\removeTag
‪removeTag(Tag $tag)
Definition: Post.php:192
‪TYPO3\CMS\Extbase\Domain\Model\Category
Definition: Category.php:26
‪ExtbaseTeam\BlogExample\Domain\Model\Person
Definition: Person.php:25
‪ExtbaseTeam\BlogExample\Domain\Model\Post\removeAllComments
‪removeAllComments()
Definition: Post.php:361
‪ExtbaseTeam\BlogExample\Domain\Model\Post\addTag
‪addTag(Tag $tag)
Definition: Post.php:182
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setCategories
‪setCategories($categories)
Definition: Post.php:231
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$comments
‪TYPO3 CMS Extbase Persistence ObjectStorage<\ExtbaseTeam\BlogExample\Domain\Model\Comment > $comments
Definition: Post.php:70
‪ExtbaseTeam\BlogExample\Domain\Model\Post\__toString
‪string __toString()
Definition: Post.php:494
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$additionalName
‪ExtbaseTeam BlogExample Domain Model Info $additionalName
Definition: Post.php:80
‪ExtbaseTeam\BlogExample\Domain\Model
Definition: Administrator.php:16
‪ExtbaseTeam\BlogExample\Domain\Model\Post\setAdditionalComments
‪setAdditionalComments(ObjectStorage $additionalComments)
Definition: Post.php:459
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getAdditionalComments
‪TYPO3 CMS Extbase Persistence ObjectStorage getAdditionalComments()
Definition: Post.php:451
‪ExtbaseTeam\BlogExample\Domain\Model\Post\removeAllRelatedPosts
‪removeAllRelatedPosts()
Definition: Post.php:400
‪ExtbaseTeam\BlogExample\Domain\Model\Post\addCategory
‪addCategory(Category $category)
Definition: Post.php:221
‪ExtbaseTeam\BlogExample\Domain\Model\Tag
Definition: Tag.php:24
‪ExtbaseTeam\BlogExample\Domain\Model\Post\removeAllTags
‪removeAllTags()
Definition: Post.php:200
‪ExtbaseTeam\BlogExample\Domain\Model\Post\$author
‪ExtbaseTeam BlogExample Domain Model Person $author
Definition: Post.php:43