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

deleteAction() public method

Deletes a PersonTitle entity.
public deleteAction ( Request $request, integer $id ) : RedirectResponse
$request Symfony\Component\HttpFoundation\Request
$id integer
return Symfony\Component\HttpFoundation\RedirectResponse
    public function deleteAction(Request $request, $id)
    {
        $deleteService = $this->get('ojs_core.delete.service');
        $em = $this->getDoctrine()->getManager();
        $entity = $em->getRepository('OjsJournalBundle:PersonTitle')->find($id);
        $this->throw404IfNotFound($entity);
        if (!$this->isGranted('DELETE', $entity)) {
            throw new AccessDeniedException("You are not authorized for this page!");
        }
        $csrf = $this->get('security.csrf.token_manager');
        $token = $csrf->getToken('ojs_admin_person_title' . $entity->getId());
        if ($token != $request->get('_token')) {
            throw new TokenNotFoundException("Token not found!");
        }
        $deleteService->check($entity);
        $em->remove($entity);
        $em->flush();
        $this->successFlashBag('successful.remove');
        return $this->redirectToRoute('ojs_admin_person_title_index');
    }