/** * Mark a whole forum as read * @param Forum $forum * * @throws NotLoggedInException * @return void */ public function markReadAction(Forum $forum) { $user = $this->getCurrentUser(); if ($user->isAnonymous()) { throw new NotLoggedInException("You need to be logged in.", 1288084981); } $forumStorage = array(); $forumStorage[] = $forum; foreach ($forum->getChildren() as $children) { $forumStorage[] = $children; } foreach ($forumStorage as $checkForum) { /** @var Forum $checkForum */ foreach ($checkForum->getTopics() as $topic) { /** @var Topic $topic */ $topic->addReader($user); } $checkForum->addReader($user); $this->forumRepository->update($checkForum); } $this->redirect('show', 'Forum', NULL, array('forum' => $forum)); }
/** * Sets a post as solution * * @param Topic $topic * @param Post $post */ public function setPostAsSolution(Topic $topic, Post $post) { $topic->setSolution($post); $this->topicRepository->update($topic); $this->forumRepository->update($topic->getForum()); }