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

deleteAction() public method

Deletes a JournalContact 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)
    {
        $em = $this->getDoctrine()->getManager();
        /** @var JournalContact $entity */
        $entity = $em->getRepository('OjsJournalBundle:JournalContact')->findOneBy(['id' => $id]);
        $this->throw404IfNotFound($entity);
        /** @var $dispatcher EventDispatcherInterface */
        $dispatcher = $this->get('event_dispatcher');
        $csrf = $this->get('security.csrf.token_manager');
        $token = $csrf->getToken('ojs_admin_contact' . $entity->getId());
        if ($token != $request->get('_token')) {
            throw new TokenNotFoundException("Token Not Found!");
        }
        $this->get('ojs_core.delete.service')->check($entity);
        $event = new AdminEvent(['eventType' => 'delete', 'entity' => $entity]);
        $dispatcher->dispatch(AdminEvents::ADMIN_CONTACT_CHANGE, $event);
        $em->remove($entity);
        $em->flush();
        $this->successFlashBag('successful.remove');
        return $this->redirectToRoute('ojs_admin_contact_index');
    }