Ojs\JournalBundle\Controller\BlockController::deleteAction PHP Метод

deleteAction() публичный Метод

Deletes a Block entity.
public deleteAction ( Request $request, Block $entity ) : RedirectResponse
$request Symfony\Component\HttpFoundation\Request
$entity Ojs\JournalBundle\Entity\Block
Результат Symfony\Component\HttpFoundation\RedirectResponse
    public function deleteAction(Request $request, Block $entity)
    {
        $journal = $this->get('ojs.journal_service')->getSelectedJournal();
        if (!$this->isGranted('DELETE', $journal, 'block')) {
            throw new AccessDeniedException("You not authorized for delete this page!");
        }
        $em = $this->getDoctrine()->getManager();
        $csrf = $this->get('security.csrf.token_manager');
        $token = $csrf->getToken('ojs_journal_block' . $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_journal_block_index', ['journalId' => $journal->getId()]);
    }