Ojs\AdminBundle\Controller\AdminContactTypeController::deleteAction PHP Method

deleteAction() public method

Deletes a ContactTypes entity.
public deleteAction ( Request $request, $id ) : RedirectResponse
$request Symfony\Component\HttpFoundation\Request
$id
return Symfony\Component\HttpFoundation\RedirectResponse
    public function deleteAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();
        $entity = $em->getRepository('OjsJournalBundle:ContactTypes')->find($id);
        $this->throw404IfNotFound($entity);
        $csrf = $this->get('security.csrf.token_manager');
        $token = $csrf->getToken('ojs_admin_contact_type' . $id);
        if ($token != $request->get('_token')) {
            throw new TokenNotFoundException("Token Not Found!");
        }
        $this->get('ojs_core.delete.service')->check($entity);
        $em->remove($entity);
        $em->flush();
        $this->successFlashBag('successful.remove');
        return $this->redirect($this->generateUrl('ojs_admin_contact_type_index'));
    }