public function createSubjectAction(Category $category)
    {
        $forum = $category->getForum();
        $collection = new ResourceCollection(array($forum->getResourceNode()));

        if (!$this->authorization->isGranted('post', $collection)) {
            throw new AccessDeniedException($collection->getErrorsForDisplay());
        }

        $form = $this->get('form.factory')->create(new SubjectType(), new Subject);
        $form->handleRequest($this->get('request'));

        if ($form->isValid()) {
            $user = $this->tokenStorage->getToken()->getUser();
            $subject = $form->getData();
            $subject->setCreator($user);
            $subject->setAuthor($user->getFirstName() . ' ' . $user->getLastName());
            //instantiation of the new resources
            $subject->setCategory($category);
            $this->manager->createSubject($subject);
            $dataMessage = $form->get('message')->getData();

            if ($dataMessage['content'] !== null) {
                $message = new Message();
                $message->setContent($dataMessage['content']);
                $message->setCreator($user);
                $message->setAuthor($user->getFirstName() . ' ' . $user->getLastName());
                $message->setSubject($subject);
                $this->manager->createMessage($message, $subject);

                return new RedirectResponse(
                    $this->generateUrl('claro_forum_subjects', array('category' => $category->getId()))
                );
            }
        }

        $form->get('message')->addError(
            new FormError($this->get('translator')->trans('field_content_required', array(), 'forum'))
        );

        return array(
            'form' => $form->createView(),
            '_resource' => $forum,
            'workspace' => $forum->getResourceNode()->getWorkspace()
        );
    }
public function createSubjectAction(Category $category)
    {
        $forum = $category->getForum();
        $collection = new ResourceCollection(array($forum->getResourceNode()));

        if (!$this->authorization->isGranted('post', $collection)) {
            throw new AccessDeniedException($collection->getErrorsForDisplay());
        }

        $form = $this->get('form.factory')->create(new SubjectType(), new Subject);
        $form->handleRequest($this->get('request'));

        if ($form->isValid()) {
            $user = $this->tokenStorage->getToken()->getUser();
            $subject = $form->getData();
            $subject->setCreator($user);
            $subject->setAuthor($user->getFirstName() . ' ' . $user->getLastName());
            //instantiation of the new resources
            $subject->setCategory($category);
            $this->manager->createSubject($subject);
            $dataMessage = $form->get('message')->getData();

            if ($dataMessage['content'] !== null) {
                $message = new Message();
                $message->setContent($dataMessage['content']);
                $message->setCreator($user);
                $message->setAuthor($user->getFirstName() . ' ' . $user->getLastName());
                $message->setSubject($subject);
                $this->manager->createMessage($message, $subject);

                return new RedirectResponse(
                    $this->generateUrl('claro_forum_subjects', array('category' => $category->getId()))
                );
            }
        }

        $form->get('message')->addError(
            new FormError($this->get('translator')->trans('field_content_required', array(), 'forum'))
        );

        return array(
            'form' => $form->createView(),
            '_resource' => $forum,
            'workspace' => $forum->getResourceNode()->getWorkspace()
        );
    }
public function createSubjectAction ( Category $ category ) { $ forum = $ category -> getForum ( ) ; $ collection = new ResourceCollection ( array ( $ forum -> getResourceNode ( ) ) ) ; if ( ! $ this -> authorization -> isGranted ( 'post' , $ collection ) ) { throw new AccessDeniedException ( $ collection -> getErrorsForDisplay ( ) ) ; } $ form = $ this -> get ( 'form.factory' ) -> create ( new SubjectType ( ) , new Subject ) ; $ form -> handleRequest ( $ this -> get ( 'request' ) ) ; if ( $ form -> isValid ( ) ) { $ user = $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ; $ subject = $ form -> getData ( ) ; $ subject -> setCreator ( $ user ) ; $ subject -> setAuthor ( $ user -> getFirstName ( ) . ' ' . $ user -> getLastName ( ) ) ; //instantiation of the new resources $ subject -> setCategory ( $ category ) ; $ this -> manager -> createSubject ( $ subject ) ; $ dataMessage = $ form -> get ( 'message' ) -> getData ( ) ; if ( $ dataMessage [ 'content' ] !== null ) { $ message = new Message ( ) ; $ message -> setContent ( $ dataMessage [ 'content' ] ) ; $ message -> setCreator ( $ user ) ; $ message -> setAuthor ( $ user -> getFirstName ( ) . ' ' . $ user -> getLastName ( ) ) ; $ message -> setSubject ( $ subject ) ; $ this -> manager -> createMessage ( $ message , $ subject ) ; return new RedirectResponse ( $ this -> generateUrl ( 'claro_forum_subjects' , array ( 'category' => $ category -> getId ( ) ) ) ) ; } } $ form -> get ( 'message' ) -> addError ( new FormError ( $ this -> get ( 'translator' ) -> trans ( 'field_content_required' , array ( ) , 'forum' ) ) ) ; return array ( 'form' => $ form -> createView ( ) , '_resource' => $ forum , 'workspace' => $ forum -> getResourceNode ( ) -> getWorkspace ( ) ) ; }
The form submission is working but I had to do some weird things to make it works.

@Route(
"/subject/create/{category}",
name="claro_forum_create_subject"
)
@ParamConverter("authenticatedUser", options={"authenticatedUser" = true})
@Template("ClarolineForumBundle:Forum:subjectForm.html.twig")
@param Category $category
@throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
@throws \Exception
@return array|\Symfony\Component\HttpFoundation\RedirectResponse
The form submission is working but I had to do some weird things to make it works .