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

deleteAction() public method

Deletes a Post entity.
public deleteAction ( Request $request, AdminPost $entity ) : RedirectResponse
$request Symfony\Component\HttpFoundation\Request
$entity Ojs\AdminBundle\Entity\AdminPost
return Symfony\Component\HttpFoundation\RedirectResponse
    public function deleteAction(Request $request, AdminPost $entity)
    {
        $this->throw404IfNotFound($entity);
        $em = $this->getDoctrine()->getManager();
        $csrf = $this->get('security.csrf.token_manager');
        $token = $csrf->getToken('ojs_admin_post' . $entity->getId());
        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->redirectToRoute('ojs_admin_post_index');
    }