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

        // Not Found
        if (null === $mailTemplate) {
            $this->addFlash('error', 'sorry_not_existing');

            return $this->redirectToRoute('admin_mail_list');
        }

        // Remove Template
        $em = $this->getDoctrine()->getManager();
        $em->remove($mailTemplate);
        $em->flush();

        // Redirect Back
        return $this->redirect($request->headers->get('referer') ?? $this->generateUrl('admin_mail_list'));
    }
public function deleteTemplate(Request $request, $id)
    {
        // Find Template
        $mailTemplate = $this
            ->getDoctrine()
            ->getRepository($this->getParameter('pd_mailer.mail_template_class'))
            ->findOneBy(['id' => $id]);

        // Not Found
        if (null === $mailTemplate) {
            $this->addFlash('error', 'sorry_not_existing');

            return $this->redirectToRoute('admin_mail_list');
        }

        // Remove Template
        $em = $this->getDoctrine()->getManager();
        $em->remove($mailTemplate);
        $em->flush();

        // Redirect Back
        return $this->redirect($request->headers->get('referer') ?? $this->generateUrl('admin_mail_list'));
    }
public function deleteTemplate ( Request $ request , $ id ) { // Find Template $ mailTemplate = $ this -> getDoctrine ( ) -> getRepository ( $ this -> getParameter ( 'pd_mailer.mail_template_class' ) ) -> findOneBy ( [ 'id' => $ id ] ) ; // Not Found if ( null === $ mailTemplate ) { $ this -> addFlash ( 'error' , 'sorry_not_existing' ) ; return $ this -> redirectToRoute ( 'admin_mail_list' ) ; } // Remove Template $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> remove ( $ mailTemplate ) ; $ em -> flush ( ) ; // Redirect Back return $ this -> redirect ( $ request -> headers -> get ( 'referer' ) ?? $ this -> generateUrl ( 'admin_mail_list' ) ) ; }
Delete Templates.

@param Request $request
@param MailTemplate $mailTemplate

@IsGranted("ROLE_MAIL_TEMPLATEDELETE")

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