TYPO3 CMS  TYPO3_6-2
Post.php
Go to the documentation of this file.
1 <?php
20 
24  protected $blog = NULL;
25 
30  protected $title = '';
31 
35  protected $date = NULL;
36 
40  protected $author = NULL;
41 
46  protected $content = '';
47 
51  protected $tags = NULL;
52 
56  protected $categories = NULL;
57 
63  protected $comments = NULL;
64 
69  protected $relatedPosts = NULL;
70 
74  public function __construct() {
75  $this->tags = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
76  $this->categories = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
77  $this->comments = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
78  $this->relatedPosts = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
79  $this->date = new \DateTime();
80  }
81 
88  public function setBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog) {
89  $this->blog = $blog;
90  }
91 
97  public function getBlog() {
98  return $this->blog;
99  }
100 
107  public function setTitle($title) {
108  $this->title = $title;
109  }
110 
116  public function getTitle() {
117  return $this->title;
118  }
119 
126  public function setDate(\DateTime $date) {
127  $this->date = $date;
128  }
129 
136  public function getDate() {
137  return $this->date;
138  }
139 
146  public function setTags(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $tags) {
147  $this->tags = $tags;
148  }
149 
156  public function addTag(Tag $tag) {
157  $this->tags->attach($tag);
158  }
159 
166  public function removeTag(Tag $tag) {
167  $this->tags->detach($tag);
168  }
169 
175  public function removeAllTags() {
176  $this->tags = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
177  }
178 
185  public function getTags() {
186  return clone $this->tags;
187  }
188 
194  public function addCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category) {
195  $this->categories->attach($category);
196  }
197 
203  public function setCategories($categories) {
204  $this->categories = $categories;
205  }
206 
212  public function getCategories() {
213  return $this->categories;
214  }
215 
221  public function removeCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category) {
222  $this->categories->detach($category);
223  }
224 
231  public function setAuthor(\ExtbaseTeam\BlogExample\Domain\Model\Person $author) {
232  $this->author = $author;
233  }
234 
240  public function getAuthor() {
241  return $this->author;
242  }
243 
250  public function setContent($content) {
251  $this->content = $content;
252  }
253 
259  public function getContent() {
260  return $this->content;
261  }
262 
269  public function setComments(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $comments) {
270  $this->comments = $comments;
271  }
272 
279  public function addComment(Comment $comment) {
280  $this->comments->attach($comment);
281  }
282 
289  public function removeComment(Comment $commentToDelete) {
290  $this->comments->detach($commentToDelete);
291  }
292 
298  public function removeAllComments() {
299  $comments = clone $this->comments;
300  $this->comments->removeAll($comments);
301  }
302 
308  public function getComments() {
309  return $this->comments;
310  }
311 
318  public function setRelatedPosts(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $relatedPosts) {
319  $this->relatedPosts = $relatedPosts;
320  }
321 
328  public function addRelatedPost(Post $post) {
329  $this->relatedPosts->attach($post);
330  }
331 
337  public function removeAllRelatedPosts() {
339  $this->relatedPosts->removeAll($relatedPosts);
340  }
341 
347  public function getRelatedPosts() {
348  return $this->relatedPosts;
349  }
350 
356  public function __toString() {
357  return $this->title . chr(10) .
358  ' written on ' . $this->date->format('Y-m-d') . chr(10) .
359  ' by ' . $this->author->getFullName() . chr(10) .
360  wordwrap($this->content, 70, chr(10)) . chr(10) .
361  implode(', ', $this->tags->toArray());
362  }
363 }
364 ?>
removeTag(Tag $tag)
Definition: Post.php:166
getBlog()
Definition: Post.php:97
__construct()
Definition: Post.php:74
removeAllComments()
Definition: Post.php:298
$title
Definition: Post.php:30
setAuthor(\ExtbaseTeam\BlogExample\Domain\Model\Person $author)
Definition: Post.php:231
setBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
Definition: Post.php:88
$author
Definition: Post.php:40
getAuthor()
Definition: Post.php:240
getRelatedPosts()
Definition: Post.php:347
$content
Definition: Post.php:46
$blog
Definition: Post.php:24
getTitle()
Definition: Post.php:116
removeAllRelatedPosts()
Definition: Post.php:337
setTags(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $tags)
Definition: Post.php:146
removeComment(Comment $commentToDelete)
Definition: Post.php:289
$comments
Definition: Post.php:63
getCategories()
Definition: Post.php:212
getContent()
Definition: Post.php:259
removeCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category)
Definition: Post.php:221
addComment(Comment $comment)
Definition: Post.php:279
__toString()
Definition: Post.php:356
getComments()
Definition: Post.php:308
getDate()
Definition: Post.php:136
addCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category)
Definition: Post.php:194
setRelatedPosts(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $relatedPosts)
Definition: Post.php:318
$tags
Definition: Post.php:51
Definition: Post.php:19
setCategories($categories)
Definition: Post.php:203
$date
Definition: Post.php:35
addTag(Tag $tag)
Definition: Post.php:156
setComments(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $comments)
Definition: Post.php:269
getTags()
Definition: Post.php:185
removeAllTags()
Definition: Post.php:175
setDate(\DateTime $date)
Definition: Post.php:126
setContent($content)
Definition: Post.php:250
setTitle($title)
Definition: Post.php:107
$relatedPosts
Definition: Post.php:69
$categories
Definition: Post.php:56
addRelatedPost(Post $post)
Definition: Post.php:328