TYPO3 CMS  TYPO3_8-7
Post.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected $blog = null;
26 
31  protected $title = '';
32 
36  protected $date = null;
37 
41  protected $author = null;
42 
46  protected $secondAuthor;
47 
51  protected $reviewer = null;
52 
57  protected $content = '';
58 
62  protected $tags = null;
63 
67  protected $categories = null;
68 
74  protected $comments = null;
75 
80  protected $relatedPosts = null;
81 
86  protected $additionalName;
87 
92  protected $additionalInfo;
93 
100 
104  public function __construct()
105  {
106  $this->tags = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
107  $this->categories = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
108  $this->comments = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
109  $this->relatedPosts = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
110  $this->date = new \DateTime();
111  $this->additionalComments = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
112  }
113 
119  public function setBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
120  {
121  $this->blog = $blog;
122  }
123 
129  public function getBlog()
130  {
131  return $this->blog;
132  }
133 
139  public function setTitle($title)
140  {
141  $this->title = $title;
142  }
143 
149  public function getTitle()
150  {
151  return $this->title;
152  }
153 
159  public function setDate(\DateTime $date)
160  {
161  $this->date = $date;
162  }
163 
170  public function getDate()
171  {
172  return $this->date;
173  }
174 
180  public function setTags(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $tags)
181  {
182  $this->tags = $tags;
183  }
184 
190  public function addTag(Tag $tag)
191  {
192  $this->tags->attach($tag);
193  }
194 
200  public function removeTag(Tag $tag)
201  {
202  $this->tags->detach($tag);
203  }
204 
208  public function removeAllTags()
209  {
210  $this->tags = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
211  }
212 
219  public function getTags()
220  {
221  return clone $this->tags;
222  }
223 
229  public function addCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category)
230  {
231  $this->categories->attach($category);
232  }
233 
239  public function setCategories($categories)
240  {
241  $this->categories = $categories;
242  }
243 
249  public function getCategories()
250  {
251  return $this->categories;
252  }
253 
259  public function removeCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category)
260  {
261  $this->categories->detach($category);
262  }
263 
269  public function setAuthor(\ExtbaseTeam\BlogExample\Domain\Model\Person $author)
270  {
271  $this->author = $author;
272  }
273 
279  public function getAuthor()
280  {
281  return $this->author;
282  }
283 
287  public function getSecondAuthor()
288  {
289  return $this->secondAuthor;
290  }
291 
295  public function setSecondAuthor(\ExtbaseTeam\BlogExample\Domain\Model\Person $secondAuthor)
296  {
297  $this->secondAuthor = $secondAuthor;
298  }
299 
303  public function getReviewer()
304  {
305  return $this->reviewer;
306  }
307 
311  public function setReviewer(\ExtbaseTeam\BlogExample\Domain\Model\Person $reviewer)
312  {
313  $this->reviewer = $reviewer;
314  }
315 
321  public function setContent($content)
322  {
323  $this->content = $content;
324  }
325 
331  public function getContent()
332  {
333  return $this->content;
334  }
335 
341  public function setComments(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $comments)
342  {
343  $this->comments = $comments;
344  }
345 
351  public function addComment(Comment $comment)
352  {
353  $this->comments->attach($comment);
354  }
355 
361  public function removeComment(Comment $commentToDelete)
362  {
363  $this->comments->detach($commentToDelete);
364  }
365 
369  public function removeAllComments()
370  {
371  $comments = clone $this->comments;
372  $this->comments->removeAll($comments);
373  }
374 
380  public function getComments()
381  {
382  return $this->comments;
383  }
384 
390  public function setRelatedPosts(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $relatedPosts)
391  {
392  $this->relatedPosts = $relatedPosts;
393  }
394 
400  public function addRelatedPost(Post $post)
401  {
402  $this->relatedPosts->attach($post);
403  }
404 
408  public function removeAllRelatedPosts()
409  {
411  $this->relatedPosts->removeAll($relatedPosts);
412  }
413 
419  public function getRelatedPosts()
420  {
421  return $this->relatedPosts;
422  }
423 
427  public function getAdditionalName()
428  {
429  return $this->additionalName;
430  }
431 
436  {
437  $this->additionalName = $additionalName;
438  }
439 
443  public function getAdditionalInfo()
444  {
445  return $this->additionalInfo;
446  }
447 
452  {
453  $this->additionalInfo = $additionalInfo;
454  }
455 
459  public function getAdditionalComments(): \TYPO3\CMS\Extbase\Persistence\ObjectStorage
460  {
462  }
463 
467  public function setAdditionalComments(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalComments)
468  {
469  $this->additionalComments = $additionalComments;
470  }
471 
475  public function addAdditionalComment(Comment $comment)
476  {
477  $this->additionalComments->attach($comment);
478  }
479 
483  public function removeAllAdditionalComments()
484  {
486  $this->additionalComments->removeAll($comments);
487  }
488 
492  public function removeAdditionalComment(Comment $comment)
493  {
494  $this->additionalComments->detach($comment);
495  }
496 
502  public function __toString()
503  {
504  return $this->title . chr(10) .
505  ' written on ' . $this->date->format('Y-m-d') . chr(10) .
506  ' by ' . $this->author->getFullName() . chr(10) .
507  wordwrap($this->content, 70, chr(10)) . chr(10) .
508  implode(', ', $this->tags->toArray());
509  }
510 }
removeTag(Tag $tag)
Definition: Post.php:200
getBlog()
Definition: Post.php:129
__construct()
Definition: Post.php:104
removeAdditionalComment(Comment $comment)
Definition: Post.php:492
removeAllComments()
Definition: Post.php:369
$title
Definition: Post.php:31
setAuthor(\ExtbaseTeam\BlogExample\Domain\Model\Person $author)
Definition: Post.php:269
removeAllAdditionalComments()
Definition: Post.php:483
setSecondAuthor(\ExtbaseTeam\BlogExample\Domain\Model\Person $secondAuthor)
Definition: Post.php:295
setBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
Definition: Post.php:119
$secondAuthor
Definition: Post.php:46
getSecondAuthor()
Definition: Post.php:287
$author
Definition: Post.php:41
getAuthor()
Definition: Post.php:279
getAdditionalName()
Definition: Post.php:427
getRelatedPosts()
Definition: Post.php:419
$content
Definition: Post.php:57
$additionalInfo
Definition: Post.php:92
$reviewer
Definition: Post.php:51
$blog
Definition: Post.php:25
setAdditionalComments(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalComments)
Definition: Post.php:467
getTitle()
Definition: Post.php:149
removeAllRelatedPosts()
Definition: Post.php:408
setTags(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $tags)
Definition: Post.php:180
removeComment(Comment $commentToDelete)
Definition: Post.php:361
$comments
Definition: Post.php:74
getCategories()
Definition: Post.php:249
getContent()
Definition: Post.php:331
removeCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category)
Definition: Post.php:259
addComment(Comment $comment)
Definition: Post.php:351
__toString()
Definition: Post.php:502
getComments()
Definition: Post.php:380
getDate()
Definition: Post.php:170
addCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category)
Definition: Post.php:229
setRelatedPosts(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $relatedPosts)
Definition: Post.php:390
$tags
Definition: Post.php:62
Definition: Post.php:20
setCategories($categories)
Definition: Post.php:239
$additionalComments
Definition: Post.php:99
$date
Definition: Post.php:36
addTag(Tag $tag)
Definition: Post.php:190
setAdditionalInfo(Info $additionalInfo)
Definition: Post.php:451
setComments(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $comments)
Definition: Post.php:341
setReviewer(\ExtbaseTeam\BlogExample\Domain\Model\Person $reviewer)
Definition: Post.php:311
getTags()
Definition: Post.php:219
getReviewer()
Definition: Post.php:303
removeAllTags()
Definition: Post.php:208
setDate(\DateTime $date)
Definition: Post.php:159
$additionalName
Definition: Post.php:86
getAdditionalInfo()
Definition: Post.php:443
setContent($content)
Definition: Post.php:321
setTitle($title)
Definition: Post.php:139
getAdditionalComments()
Definition: Post.php:459
addAdditionalComment(Comment $comment)
Definition: Post.php:475
setAdditionalName(Info $additionalName)
Definition: Post.php:435
$relatedPosts
Definition: Post.php:80
$categories
Definition: Post.php:67
addRelatedPost(Post $post)
Definition: Post.php:400