BlogBundle/Controller/BlogController.php
public function resolve(Comment $comment, Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $postId = $request->query->get('post');
        $itemForm = $request->get('comment_front');

        if( $this->container->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY') ){
            $comment->setActor($this->container->get('security.token_storage')->getToken()->getUser());
        }else{
            //register user
            $actor = $this->createActor($itemForm);
            $comment->setActor($actor);
        }
        
        $postRepository = $em->getRepository('BlogBundle:Post');
        if (!$postId || !$post = $postRepository->find($postId)) {
            // no product id given, or product not found
            throw new \Exception('Requested post was not found');
        }

        // assign the product and quantity to the item
        $comment->setPost($post);
        $comment->setComment($itemForm['comment']);
        
        return $comment;
    }
public function resolve(Comment $comment, Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $postId = $request->query->get('post');
        $itemForm = $request->get('comment_front');

        if( $this->container->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY') ){
            $comment->setActor($this->container->get('security.token_storage')->getToken()->getUser());
        }else{
            //register user
            $actor = $this->createActor($itemForm);
            $comment->setActor($actor);
        }
        
        $postRepository = $em->getRepository('BlogBundle:Post');
        if (!$postId || !$post = $postRepository->find($postId)) {
            // no product id given, or product not found
            throw new \Exception('Requested post was not found');
        }

        // assign the product and quantity to the item
        $comment->setPost($post);
        $comment->setComment($itemForm['comment']);
        
        return $comment;
    }
public function resolve ( Comment $ comment , Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ postId = $ request -> query -> get ( 'post' ) ; $ itemForm = $ request -> get ( 'comment_front' ) ; if ( $ this -> container -> get ( 'security.authorization_checker' ) -> isGranted ( 'IS_AUTHENTICATED_FULLY' ) ) { $ comment -> setActor ( $ this -> container -> get ( 'security.token_storage' ) -> getToken ( ) -> getUser ( ) ) ; } else { //register user $ actor = $ this -> createActor ( $ itemForm ) ; $ comment -> setActor ( $ actor ) ; } $ postRepository = $ em -> getRepository ( 'BlogBundle:Post' ) ; if ( ! $ postId || ! $ post = $ postRepository -> find ( $ postId ) ) { // no product id given, or product not found throw new \ Exception ( 'Requested post was not found' ) ; } // assign the product and quantity to the item $ comment -> setPost ( $ post ) ; $ comment -> setComment ( $ itemForm [ 'comment' ] ) ; return $ comment ; }
@param Comment $comment
@param Request $request

@throws ItemResolvingException
@return CartItemInterface|void
@param Comment $comment @param Request $request