AppBundle\Controller\BlogController::commentNewAction PHP Метод

commentNewAction() публичный Метод

public commentNewAction ( Request $request, Post $post )
$request Symfony\Component\HttpFoundation\Request
$post AppBundle\Entity\Post
    public function commentNewAction(Request $request, Post $post)
    {
        $form = $this->createForm('AppBundle\\Form\\CommentType');
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            /** @var Comment $comment */
            $comment = $form->getData();
            $comment->setAuthorEmail($this->getUser()->getEmail());
            $comment->setPost($post);
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($comment);
            $entityManager->flush();
            return $this->redirectToRoute('blog_post', array('slug' => $post->getSlug()));
        }
        return $this->render('blog/comment_form_error.html.twig', array('post' => $post, 'form' => $form->createView()));
    }