public function newAction(Request $request, $access)
    {
        $message = new Message();
        if ($message_type = $request->get('message_type')) {
            $em = $this->getDoctrineManager();
            $message->setMessageType(
                $em->getRepository('BisonLabSakonninBundle:MessageType')
                    ->find($message_type)
            );
        }
        $form = $this->createForm('BisonLab\SakonninBundle\Form\MessageType',
            $message);
        $form->handleRequest($request);

        // Should or should not use the service createmessage here?
        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrineManager();
            $message->setFromType('INTERNAL');
            $em->persist($message);
            $em->flush($message);

            return $this->redirectToRoute('message_show',
                array('access' => $access, 'id' => $message->getId()));
        }

        return $this->render('BisonLabSakonninBundle:Message:new.html.twig',
            array('entity' => $message, 'form'   => $form->createView()));
    }
public function newAction(Request $request, $access)
    {
        $message = new Message();
        if ($message_type = $request->get('message_type')) {
            $em = $this->getDoctrineManager();
            $message->setMessageType(
                $em->getRepository('BisonLabSakonninBundle:MessageType')
                    ->find($message_type)
            );
        }
        $form = $this->createForm('BisonLab\SakonninBundle\Form\MessageType',
            $message);
        $form->handleRequest($request);

        // Should or should not use the service createmessage here?
        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrineManager();
            $message->setFromType('INTERNAL');
            $em->persist($message);
            $em->flush($message);

            return $this->redirectToRoute('message_show',
                array('access' => $access, 'id' => $message->getId()));
        }

        return $this->render('BisonLabSakonninBundle:Message:new.html.twig',
            array('entity' => $message, 'form'   => $form->createView()));
    }
public function newAction ( Request $ request , $ access ) { $ message = new Message ( ) ; if ( $ message_type = $ request -> get ( 'message_type' ) ) { $ em = $ this -> getDoctrineManager ( ) ; $ message -> setMessageType ( $ em -> getRepository ( 'BisonLabSakonninBundle:MessageType' ) -> find ( $ message_type ) ) ; } $ form = $ this -> createForm ( 'BisonLab\SakonninBundle\Form\MessageType' , $ message ) ; $ form -> handleRequest ( $ request ) ; // Should or should not use the service createmessage here? if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrineManager ( ) ; $ message -> setFromType ( 'INTERNAL' ) ; $ em -> persist ( $ message ) ; $ em -> flush ( $ message ) ; return $ this -> redirectToRoute ( 'message_show' , array ( 'access' => $ access , 'id' => $ message -> getId ( ) ) ) ; } return $ this -> render ( 'BisonLabSakonninBundle:Message:new.html.twig' , array ( 'entity' => $ message , 'form' => $ form -> createView ( ) ) ) ; }
Creates a new person entity.

@Route("/new/", name="message_new", methods={"GET", "POST"})
Creates a new person entity .