/** * 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); }
/** * Adds a readable object to the list of objects read by this user. * * @param ReadableInterface $readObject The object that is to be marked as read. * @return void */ public function addReadObject(ReadableInterface $readObject) { if ($readObject instanceof Topic) { $this->readTopics->attach($readObject); } }