Donatas Veikutis
Donatas Veikutis

Reputation: 1004

how to disable Symfony 2.5.x twig template loader?

I have this controller action:

/**
 * @Route("/cms/comments/delete/{id}", name="_cms_comment_delete")
 * @Template()
 */
public function deleteAction($id)
{
    $comment = $this->getDoctrine()
        ->getRepository('CMSBundle:Comments')
        ->find($id);

    if (!$comment) {
        throw $this->createNotFoundException(
            'error'
        );
    }

    $em->remove($comment);
    $em->flush();
    $this->redirect($this->generateUrl('_cms_comments', array()));
}

This action do not have template and I get this error:

Unable to find template "CMSBundle:Comments:delete.html.twig"

How to turn off rendering for this action?

Edit:

When I remove @Template() annotation, I get this error:

The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller?

Upvotes: 0

Views: 445

Answers (1)

pazulx
pazulx

Reputation: 2379

Remove

 * @Template()

From method annotation.

and add return statement:

return $this->redirect($this->generateUrl('_cms_comments', array()));

Upvotes: 2

Related Questions