Next try to update the last post field in ForumTopic and ForumTopicGroup

This commit is contained in:
Polonkai Gergely 2012-07-09 13:37:01 +02:00
parent de42154b51
commit 0fad11ffd0
3 changed files with 8 additions and 7 deletions

View File

@ -63,14 +63,10 @@ class ForumController extends Controller
$post->setCreatedAt(new \DateTime('now'));
$post->setCreatedBy($this->get('security.context')->getToken()->getUser());
$post->setTopic($topic);
$topicGroup->setLastPost($post);
$topic->setLastPost($post);
$em = $this->getDoctrine()->getEntityManager();
$em->persist($post);
// FIXME: Make this next 2 lines work!
$em->persist($topic);
$em->persist($topicGroup);
$em->flush();
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_forum_post_list', array(

View File

@ -4,6 +4,9 @@ namespace KekRozsak\FrontBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use KekRozsak\FrontBundle\Entity\ForumTopic;
use KekRozsak\FrontBundle\Entity\ForumTopicGroup;
/**
* KekRozsak\FrontBundle\Entity\ForumPost
*/
@ -195,12 +198,13 @@ class ForumPost
/**
* Set topic
*
* @param KekRozsak\FrontBundle\Entity\ForumTopic $topic
* @param ForumTopic $topic
* @return ForumPost
*/
public function setTopic(\KekRozsak\FrontBundle\Entity\ForumTopic $topic = null)
public function setTopic(ForumTopic $topic)
{
$this->topic = $topic;
$topic->setLastPost($this);
return $this;
}

View File

@ -283,9 +283,10 @@ class ForumTopic
* @param KekRozsak\FrontBundle\Entity\ForumPost $lastPost
* @return ForumTopic
*/
public function setLastPost(\KekRozsak\FrontBundle\Entity\ForumPost $lastPost = null)
public function setLastPost(\KekRozsak\FrontBundle\Entity\ForumPost $lastPost)
{
$this->lastPost = $lastPost;
$this->topic_group->setLastPost($lastPost);
return $this;
}