Controller/MailController.php
public function editTemplate(Request $request, ParameterBagInterface $bag, $id)
    {
        // Find Template
        $mailTemplate = $this
            ->getDoctrine()
            ->getRepository($this->getParameter('pd_mailer.mail_template_class'))
            ->findOneBy(['id' => $id]);
        if (!$mailTemplate) throw $this->createNotFoundException();

        // Create Form
        $form = $this->createForm($this->getParameter('pd_mailer.mail_template_type'), $mailTemplate, ['parameters' => $bag]);

        // Handle Request
        $form->handleRequest($request);

        // Submit & Valid Form
        if ($form->isSubmitted() && $form->isValid()) {
            // Save
            $em = $this->getDoctrine()->getManager();
            $em->persist($mailTemplate);
            $em->flush();

            // Message
            $this->addFlash('success', 'changes_saved');
        }

        // Render Page
        return $this->render('@PdMailer/template.html.twig', [
            'form' => $form->createView(),
            'objects' => @unserialize($mailTemplate->getTemplateData()),
            'title' => 'mail_manager_template_edit',
            'description' => 'mail_manager_template_edit_desc',
            'base_template' => $this->getParameter('pd_mailer.base_template')
        ]);
    }
public function editTemplate(Request $request, ParameterBagInterface $bag, $id)
    {
        // Find Template
        $mailTemplate = $this
            ->getDoctrine()
            ->getRepository($this->getParameter('pd_mailer.mail_template_class'))
            ->findOneBy(['id' => $id]);
        if (!$mailTemplate) throw $this->createNotFoundException();

        // Create Form
        $form = $this->createForm($this->getParameter('pd_mailer.mail_template_type'), $mailTemplate, ['parameters' => $bag]);

        // Handle Request
        $form->handleRequest($request);

        // Submit & Valid Form
        if ($form->isSubmitted() && $form->isValid()) {
            // Save
            $em = $this->getDoctrine()->getManager();
            $em->persist($mailTemplate);
            $em->flush();

            // Message
            $this->addFlash('success', 'changes_saved');
        }

        // Render Page
        return $this->render('@PdMailer/template.html.twig', [
            'form' => $form->createView(),
            'objects' => @unserialize($mailTemplate->getTemplateData()),
            'title' => 'mail_manager_template_edit',
            'description' => 'mail_manager_template_edit_desc',
            'base_template' => $this->getParameter('pd_mailer.base_template')
        ]);
    }
public function editTemplate ( Request $ request , ParameterBagInterface $ bag , $ id ) { // Find Template $ mailTemplate = $ this -> getDoctrine ( ) -> getRepository ( $ this -> getParameter ( 'pd_mailer.mail_template_class' ) ) -> findOneBy ( [ 'id' => $ id ] ) ; if ( ! $ mailTemplate ) throw $ this -> createNotFoundException ( ) ; // Create Form $ form = $ this -> createForm ( $ this -> getParameter ( 'pd_mailer.mail_template_type' ) , $ mailTemplate , [ 'parameters' => $ bag ] ) ; // Handle Request $ form -> handleRequest ( $ request ) ; // Submit & Valid Form if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { // Save $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ mailTemplate ) ; $ em -> flush ( ) ; // Message $ this -> addFlash ( 'success' , 'changes_saved' ) ; } // Render Page return $ this -> render ( '@PdMailer/template.html.twig' , [ 'form' => $ form -> createView ( ) , 'objects' => @ unserialize ( $ mailTemplate -> getTemplateData ( ) ) , 'title' => 'mail_manager_template_edit' , 'description' => 'mail_manager_template_edit_desc' , 'base_template' => $ this -> getParameter ( 'pd_mailer.base_template' ) ] ) ; }
Edit Templates.

@param Request $request
@param MailTemplate $mailTemplate

@IsGranted("ROLE_MAIL_TEMPLATEEDIT")

@return \Symfony\Component\HttpFoundation\Response
Edit Templates .