src/Cpm/JovenesBundle/Controller/PlantillaController.php
/**
     * Creates a new Plantilla entity.
     *
     * @Route("/create", name="plantilla_create")
     * @Method("post")
     * @Template("CpmJovenesBundle:Plantilla:new.html.twig")
     */
Creates a new Plantilla entity.
Creates a new Plantilla entity .
public function createAction()
    {
        $entity  = new Plantilla();
        $request = $this->getRequest();
        $form    = $this->createForm(new PlantillaType(), $entity);
        $form->bindRequest($request);
        $mailer = $this->getMailer();
        $valid = false;
        try {
        	$valid = $mailer->isValidTemplate($entity->getCuerpo());
		}
		catch( \Exception $e ) {
			$this->setErrorMessage("Error al procesar la plantilla. ".$e->getMessage());
		}
        $entity->setCodigo($this->slug($entity->getAsunto()));
        if ($form->isValid() && $valid) {
            $em = $this->getDoctrine()->getEntityManager();
            $em->persist($entity);
            $em->flush();
            return $this->redirect($this->generateUrl('plantilla_show', array('id' => $entity->getId())));
        }
		$retorno = array(
			            'entity' => $entity,
			            'form'   => $form->createView()
			        );
        return $retorno; 
    }
public function createAction ( ) { $ entity = new Plantilla ( ) ; $ request = $ this -> getRequest ( ) ; $ form = $ this -> createForm ( new PlantillaType ( ) , $ entity ) ; $ form -> bindRequest ( $ request ) ; $ mailer = $ this -> getMailer ( ) ; $ valid = false ; try { $ valid = $ mailer -> isValidTemplate ( $ entity -> getCuerpo ( ) ) ; } catch ( \ Exception $ e ) { $ this -> setErrorMessage ( " Error al procesar la plantilla.  " . $ e -> getMessage ( ) ) ; } $ entity -> setCodigo ( $ this -> slug ( $ entity -> getAsunto ( ) ) ) ; if ( $ form -> isValid ( ) && $ valid ) { $ em = $ this -> getDoctrine ( ) -> getEntityManager ( ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'plantilla_show' , array ( 'id' => $ entity -> getId ( ) ) ) ) ; } $ retorno = array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) ) ; return $ retorno ; }
Creates a new Plantilla entity.
Creates a new Plantilla entity .
//FIXME