Exemplo n.º 1
0
 private function loadPosts(ObjectManager $manager)
 {
     foreach (range(1, 10) as $i) {
         $post = new Post();
         $post->setTitle($this->getRandomPostTitle());
         $post->setSummary($this->getRandomPostSummary());
         $post->setSlug($this->container->get('slugger')->slugify($post->getTitle()));
         $post->setContent($this->getPostContent());
         $post->setAuthorEmail('*****@*****.**');
         $post->setPublishedAt(new \DateTime('now - ' . $i . 'days'));
         foreach (range(1, 5) as $j) {
             $comment = new Comment();
             $comment->setAuthorEmail('*****@*****.**');
             $comment->setPublishedAt(new \DateTime('now + ' . ($i + $j) . 'seconds'));
             $comment->setContent($this->getRandomCommentContent());
             $comment->setPost($post);
             $manager->persist($comment);
             $post->addComment($comment);
         }
         $manager->persist($post);
     }
     $manager->flush();
 }
Exemplo n.º 2
0
 /**
  * Displays a form to edit an existing Answers entity.
  *
  * @Route("/post/{id}/answsers", requirements={"id" = "\d+"}, name="admin_post_answer_list")
  * @Method({"GET", "POST"})
  * @Security("post.isAuthor(user)")
  */
 public function answsersAction(Post $post, Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $answers = $em->getRepository('AcmeUserBundle:Answer')->findAnswsersByPostId($post->getId());
     //a mettre à jour
     //return $this->render('admin/blog/index.html.twig', array('posts' => $answers));
 }
 /**
  * {@inheritDoc}
  */
 public function setCommentAnswer5($commentAnswer5)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCommentAnswer5', array($commentAnswer5));
     return parent::setCommentAnswer5($commentAnswer5);
 }