‪TYPO3CMS  ‪main
Post.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
23 
28 {
29  protected ?‪Blog ‪$blog = null;
30 
34  protected string ‪$title = '';
35 
36  protected \DateTime ‪$date;
37 
38  protected ?‪Person ‪$author = null;
39 
40  protected ?‪Person ‪$secondAuthor = null;
41 
42  protected ?‪Person ‪$reviewer = null;
43 
47  protected string ‪$content = '';
48 
53 
58 
65 
71 
75  protected ?‪Info ‪$additionalName = null;
76 
80  protected ?‪Info ‪$additionalInfo = null;
81 
88 
89  public function ‪__construct()
90  {
91  $this->tags = new ‪ObjectStorage();
92  $this->categories = new ‪ObjectStorage();
93  $this->comments = new ‪ObjectStorage();
94  $this->relatedPosts = new ‪ObjectStorage();
95  $this->date = new \DateTime();
96  $this->additionalComments = new ‪ObjectStorage();
97  }
98 
102  public function ‪setBlog(‪Blog ‪$blog): void
103  {
104  $this->blog = ‪$blog;
105  }
106 
110  public function ‪getBlog(): ?‪Blog
111  {
112  return ‪$this->blog;
113  }
114 
115  public function ‪setTitle(string ‪$title): void
116  {
117  $this->title = ‪$title;
118  }
119 
120  public function ‪getTitle(): string
121  {
122  return ‪$this->title;
123  }
124 
125  public function ‪setDate(\DateTime ‪$date): void
126  {
127  $this->date = ‪$date;
128  }
129 
130  public function ‪getDate(): \DateTime
131  {
132  return ‪$this->date;
133  }
134 
138  public function ‪setTags(‪ObjectStorage ‪$tags): void
139  {
140  $this->tags = ‪$tags;
141  }
142 
143  public function ‪addTag(‪Tag $tag): void
144  {
145  $this->tags->attach($tag);
146  }
147 
148  public function ‪removeTag(‪Tag $tag): void
149  {
150  $this->tags->detach($tag);
151  }
152 
153  public function ‪removeAllTags(): void
154  {
155  $this->tags = new ‪ObjectStorage();
156  }
157 
164  public function ‪getTags(): ‪ObjectStorage
165  {
166  return clone ‪$this->tags;
167  }
168 
169  public function ‪addCategory(‪Category $category): void
170  {
171  $this->categories->attach($category);
172  }
173 
178  {
179  $this->categories = ‪$categories;
180  }
181 
186  {
187  return ‪$this->categories;
188  }
189 
190  public function ‪removeCategory(‪Category $category): void
191  {
192  $this->categories->detach($category);
193  }
194 
195  public function ‪setAuthor(‪Person ‪$author): void
196  {
197  $this->author = ‪$author;
198  }
199 
200  public function ‪getAuthor(): ?‪Person
201  {
202  return ‪$this->author;
203  }
204 
205  public function ‪getSecondAuthor(): ?‪Person
206  {
207  return ‪$this->secondAuthor;
208  }
209 
211  {
212  $this->secondAuthor = ‪$secondAuthor;
213  }
214 
215  public function ‪getReviewer(): ?‪Person
216  {
217  return ‪$this->reviewer;
218  }
219 
220  public function ‪setReviewer(‪Person ‪$reviewer): void
221  {
222  $this->reviewer = ‪$reviewer;
223  }
224 
230  public function ‪setContent(‪$content): void
231  {
232  $this->content = ‪$content;
233  }
234 
238  public function ‪getContent(): string
239  {
240  return ‪$this->content;
241  }
242 
249  {
250  $this->comments = ‪$comments;
251  }
252 
256  public function ‪addComment(‪Comment $comment): void
257  {
258  $this->comments->attach($comment);
259  }
260 
264  public function ‪removeComment(‪Comment $commentToDelete): void
265  {
266  $this->comments->detach($commentToDelete);
267  }
268 
272  public function ‪removeAllComments(): void
273  {
275  $this->comments->‪removeAll(‪$comments);
276  }
277 
283  public function ‪getComments(): ‪ObjectStorage
284  {
285  return ‪$this->comments;
286  }
287 
294  {
295  $this->relatedPosts = ‪$relatedPosts;
296  }
297 
301  public function ‪addRelatedPost(‪Post $post): void
302  {
303  $this->relatedPosts->attach($post);
304  }
305 
309  public function ‪removeAllRelatedPosts(): void
310  {
312  $this->relatedPosts->‪removeAll(‪$relatedPosts);
313  }
314 
321  {
322  return ‪$this->relatedPosts;
323  }
324 
325  public function ‪getAdditionalName(): ?‪Info
326  {
328  }
329 
331  {
332  $this->additionalName = ‪$additionalName;
333  }
334 
335  public function ‪getAdditionalInfo(): ?‪Info
336  {
338  }
339 
341  {
342  $this->additionalInfo = ‪$additionalInfo;
343  }
344 
349  {
351  }
352 
357  {
358  $this->additionalComments = ‪$additionalComments;
359  }
360 
361  public function ‪addAdditionalComment(‪Comment $comment): void
362  {
363  $this->additionalComments->attach($comment);
364  }
365 
366  public function ‪removeAllAdditionalComments(): void
367  {
369  $this->additionalComments->‪removeAll(‪$comments);
370  }
371 
372  public function ‪removeAdditionalComment(‪Comment $comment): void
373  {
374  $this->additionalComments->detach($comment);
375  }
376 
380  public function ‪__toString(): string
381  {
382  return $this->title . chr(10) .
383  ' written on ' . $this->date->format('Y-m-d') . chr(10) .
384  ' by ' . $this->author->getFullName() . chr(10) .
385  wordwrap($this->content, 70, chr(10)) . chr(10) .
386  implode(', ', $this->tags->toArray());
387  }
388 }
‪TYPO3Tests\BlogExample\Domain\Model\Post\$additionalComments
‪ObjectStorage $additionalComments
Definition: Post.php:87
‪TYPO3Tests\BlogExample\Domain\Model\Tag
Definition: Tag.php:26
‪TYPO3Tests\BlogExample\Domain\Model\Post\$tags
‪ObjectStorage $tags
Definition: Post.php:52
‪TYPO3Tests\BlogExample\Domain\Model\Post\$date
‪DateTime $date
Definition: Post.php:36
‪TYPO3Tests\BlogExample\Domain\Model\Post\__construct
‪__construct()
Definition: Post.php:89
‪TYPO3Tests\BlogExample\Domain\Model\Post\$title
‪string $title
Definition: Post.php:34
‪TYPO3Tests\BlogExample\Domain\Model\Post\$comments
‪ObjectStorage $comments
Definition: Post.php:64
‪TYPO3Tests\BlogExample\Domain\Model\Post\getContent
‪getContent()
Definition: Post.php:238
‪TYPO3Tests\BlogExample\Domain\Model\Category
Definition: Category.php:28
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:18
‪TYPO3Tests\BlogExample\Domain\Model\Post\setComments
‪setComments(ObjectStorage $comments)
Definition: Post.php:248
‪TYPO3Tests\BlogExample\Domain\Model\Post\$additionalName
‪Info $additionalName
Definition: Post.php:75
‪TYPO3Tests\BlogExample\Domain\Model\Post\getTags
‪ObjectStorage< Tag > getTags()
Definition: Post.php:164
‪TYPO3Tests\BlogExample\Domain\Model\Post\setRelatedPosts
‪setRelatedPosts(ObjectStorage $relatedPosts)
Definition: Post.php:293
‪TYPO3Tests\BlogExample\Domain\Model\Post\$reviewer
‪Person $reviewer
Definition: Post.php:42
‪TYPO3Tests\BlogExample\Domain\Model\Post\getReviewer
‪getReviewer()
Definition: Post.php:215
‪TYPO3Tests\BlogExample\Domain\Model\Post\$content
‪string $content
Definition: Post.php:47
‪TYPO3Tests\BlogExample\Domain\Model\Post\setAdditionalName
‪setAdditionalName(Info $additionalName)
Definition: Post.php:330
‪TYPO3Tests\BlogExample\Domain\Model\Post\setContent
‪setContent($content)
Definition: Post.php:230
‪TYPO3Tests\BlogExample\Domain\Model\Post\getAdditionalComments
‪ObjectStorage< Comment > getAdditionalComments()
Definition: Post.php:348
‪TYPO3Tests\BlogExample\Domain\Model\Post\addCategory
‪addCategory(Category $category)
Definition: Post.php:169
‪TYPO3Tests\BlogExample\Domain\Model\Post\getSecondAuthor
‪getSecondAuthor()
Definition: Post.php:205
‪TYPO3Tests\BlogExample\Domain\Model\Post\getComments
‪ObjectStorage< Comment > getComments()
Definition: Post.php:283
‪TYPO3\CMS\Extbase\DomainObject\AbstractEntity
Definition: AbstractEntity.php:22
‪TYPO3Tests\BlogExample\Domain\Model\Post\$author
‪Person $author
Definition: Post.php:38
‪TYPO3Tests\BlogExample\Domain\Model\Post\$secondAuthor
‪Person $secondAuthor
Definition: Post.php:40
‪TYPO3Tests\BlogExample\Domain\Model\Post\getCategories
‪ObjectStorage< Category > getCategories()
Definition: Post.php:185
‪TYPO3\CMS\Extbase\Persistence\ObjectStorage
Definition: ObjectStorage.php:34
‪TYPO3Tests\BlogExample\Domain\Model\Post\setSecondAuthor
‪setSecondAuthor(Person $secondAuthor)
Definition: Post.php:210
‪TYPO3Tests\BlogExample\Domain\Model\Comment
Definition: Comment.php:27
‪TYPO3Tests\BlogExample\Domain\Model\Post\setDate
‪setDate(\DateTime $date)
Definition: Post.php:125
‪TYPO3Tests\BlogExample\Domain\Model\Post\setCategories
‪setCategories(ObjectStorage $categories)
Definition: Post.php:177
‪TYPO3Tests\BlogExample\Domain\Model\Post\getTitle
‪getTitle()
Definition: Post.php:120
‪TYPO3Tests\BlogExample\Domain\Model\Post\getAuthor
‪getAuthor()
Definition: Post.php:200
‪TYPO3Tests\BlogExample\Domain\Model
Definition: Administrator.php:18
‪TYPO3Tests\BlogExample\Domain\Model\Post\removeAllTags
‪removeAllTags()
Definition: Post.php:153
‪TYPO3Tests\BlogExample\Domain\Model\Post\$blog
‪Blog $blog
Definition: Post.php:29
‪TYPO3Tests\BlogExample\Domain\Model\Post\setAuthor
‪setAuthor(Person $author)
Definition: Post.php:195
‪TYPO3Tests\BlogExample\Domain\Model\Post\setAdditionalInfo
‪setAdditionalInfo(Info $additionalInfo)
Definition: Post.php:340
‪TYPO3Tests\BlogExample\Domain\Model\Post\getDate
‪getDate()
Definition: Post.php:130
‪TYPO3Tests\BlogExample\Domain\Model\Post\addComment
‪addComment(Comment $comment)
Definition: Post.php:256
‪TYPO3Tests\BlogExample\Domain\Model\Post\removeComment
‪removeComment(Comment $commentToDelete)
Definition: Post.php:264
‪TYPO3Tests\BlogExample\Domain\Model\Person
Definition: Person.php:27
‪TYPO3Tests\BlogExample\Domain\Model\Post
Definition: Post.php:28
‪TYPO3Tests\BlogExample\Domain\Model\Post\addRelatedPost
‪addRelatedPost(Post $post)
Definition: Post.php:301
‪TYPO3Tests\BlogExample\Domain\Model\Post\getAdditionalName
‪getAdditionalName()
Definition: Post.php:325
‪TYPO3Tests\BlogExample\Domain\Model\Post\removeAllRelatedPosts
‪removeAllRelatedPosts()
Definition: Post.php:309
‪TYPO3Tests\BlogExample\Domain\Model\Post\setTags
‪setTags(ObjectStorage $tags)
Definition: Post.php:138
‪TYPO3Tests\BlogExample\Domain\Model\Post\getAdditionalInfo
‪getAdditionalInfo()
Definition: Post.php:335
‪TYPO3Tests\BlogExample\Domain\Model\Post\removeAllAdditionalComments
‪removeAllAdditionalComments()
Definition: Post.php:366
‪TYPO3Tests\BlogExample\Domain\Model\Post\setAdditionalComments
‪setAdditionalComments(ObjectStorage $additionalComments)
Definition: Post.php:356
‪TYPO3Tests\BlogExample\Domain\Model\Post\removeTag
‪removeTag(Tag $tag)
Definition: Post.php:148
‪TYPO3Tests\BlogExample\Domain\Model\Blog
Definition: Blog.php:30
‪TYPO3Tests\BlogExample\Domain\Model\Post\$relatedPosts
‪ObjectStorage $relatedPosts
Definition: Post.php:70
‪TYPO3Tests\BlogExample\Domain\Model\Post\removeAllComments
‪removeAllComments()
Definition: Post.php:272
‪TYPO3\CMS\Extbase\Persistence\ObjectStorage\removeAll
‪removeAll(ObjectStorage $storage)
Definition: ObjectStorage.php:279
‪TYPO3Tests\BlogExample\Domain\Model\Post\addAdditionalComment
‪addAdditionalComment(Comment $comment)
Definition: Post.php:361
‪TYPO3Tests\BlogExample\Domain\Model\Post\getRelatedPosts
‪ObjectStorage< Post > getRelatedPosts()
Definition: Post.php:320
‪TYPO3Tests\BlogExample\Domain\Model\Post\setTitle
‪setTitle(string $title)
Definition: Post.php:115
‪TYPO3Tests\BlogExample\Domain\Model\Info
Definition: Info.php:26
‪TYPO3Tests\BlogExample\Domain\Model\Post\addTag
‪addTag(Tag $tag)
Definition: Post.php:143
‪TYPO3Tests\BlogExample\Domain\Model\Post\$categories
‪ObjectStorage $categories
Definition: Post.php:57
‪TYPO3Tests\BlogExample\Domain\Model\Post\removeAdditionalComment
‪removeAdditionalComment(Comment $comment)
Definition: Post.php:372
‪TYPO3Tests\BlogExample\Domain\Model\Post\__toString
‪__toString()
Definition: Post.php:380
‪TYPO3Tests\BlogExample\Domain\Model\Post\setReviewer
‪setReviewer(Person $reviewer)
Definition: Post.php:220
‪TYPO3Tests\BlogExample\Domain\Model\Post\$additionalInfo
‪Info $additionalInfo
Definition: Post.php:80
‪TYPO3Tests\BlogExample\Domain\Model\Post\removeCategory
‪removeCategory(Category $category)
Definition: Post.php:190
‪TYPO3Tests\BlogExample\Domain\Model\Post\getBlog
‪getBlog()
Definition: Post.php:110
‪TYPO3Tests\BlogExample\Domain\Model\Post\setBlog
‪setBlog(Blog $blog)
Definition: Post.php:102