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

deleteAction() public method

public deleteAction ( Request $request, AdminAnnouncement $entity ) : RedirectResponse
$request Symfony\Component\HttpFoundation\Request
$entity Ojs\AdminBundle\Entity\AdminAnnouncement
return Symfony\Component\HttpFoundation\RedirectResponse
    public function deleteAction(Request $request, AdminAnnouncement $entity)
    {
        $this->throw404IfNotFound($entity);
        $em = $this->getDoctrine()->getManager();
        $csrf = $this->get('security.csrf.token_manager');
        $token = $csrf->getToken('ojs_admin_announcement' . $entity->getId());
        if ($token != $request->get('_token')) {
            throw new TokenNotFoundException("Token not found!");
        }
        $deleteService = $this->get('ojs_core.delete.service');
        $deleteService->check($entity);
        $em->remove($entity);
        $em->flush();
        $this->successFlashBag('successful.remove');
        return $this->redirectToRoute('ojs_admin_announcement_index');
    }