Пример #1
0
 /**
  * Adds a topic.
  *
  * @param Topic $topic
  *
  * @return void
  */
 public function addTopic(Topic $topic)
 {
     if ($this->lastTopic === NULL || $this->lastTopic->getTimestamp() <= $topic->getTimestamp()) {
         $this->setLastTopic($topic);
     }
     $topicLastPost = $topic->getLastPost();
     if ($topicLastPost !== NULL && ($this->lastPost === NULL || $this->lastPost->getTimestamp() <= $topicLastPost->getTimestamp())) {
         $this->setLastPost($topic->getLastPost());
     }
     $this->_increaseTopicCount(+1);
     // topic will increase postCount itself when adding the initial post to it
     $topic->setForum($this);
     $this->topics->attach($topic);
 }
Пример #2
0
 /**
  * Sets the last post. This method is not publicy accessible; is is called
  * automatically when a new post is added to this topic.
  *
  * @param \Mittwald\Typo3Forum\Domain\Model\Forum\Post $lastPost The last post.
  *
  * @return void
  */
 protected function setLastPost(\Mittwald\Typo3Forum\Domain\Model\Forum\Post $lastPost)
 {
     $this->lastPost = $lastPost;
     $this->lastPostCrdate = $lastPost->getTimestamp();
 }