Acme\DemoBundle\Controller\TodoController::deleteTodosAction PHP Method

deleteTodosAction() public method

Removes a todo.
public deleteTodosAction ( integer $id ) : Response
$id integer the todo id
return Symfony\Component\HttpFoundation\Response
    public function deleteTodosAction($id)
    {
        $todo = $this->getDoctrine()->getRepository('AcmeDemoBundle:Todo')->find($id);
        if (!$todo) {
            throw $this->createNotFoundException("Todo does not exist.");
        }
        $em = $this->getDoctrine()->getManager();
        $em->remove($todo);
        $em->flush();
        return $this->handleView($this->routeRedirectView('get_todos', [], Codes::HTTP_NO_CONTENT));
    }