Ojs\JournalBundle\Controller\ArticleFileController::deleteAction PHP Method

deleteAction() public method

Deletes a ArticleFile entity.
public deleteAction ( Request $request, integer $id, integer $articleId ) : RedirectResponse
$request Symfony\Component\HttpFoundation\Request
$id integer
$articleId integer
return Symfony\Component\HttpFoundation\RedirectResponse
    public function deleteAction(Request $request, $id, $articleId)
    {
        $journal = $this->get('ojs.journal_service')->getSelectedJournal();
        $em = $this->getDoctrine()->getManager();
        if (!$this->isGranted('EDIT', $journal, 'articles')) {
            throw new AccessDeniedException("You not authorized for this page!");
        }
        /** @var Article $article */
        $article = $em->getRepository('OjsJournalBundle:Article')->find($articleId);
        $this->throw404IfNotFound($article);
        /** @var ArticleFile $entity */
        $entity = $em->getRepository('OjsJournalBundle:ArticleFile')->findOneBy(['article' => $article, 'id' => $id]);
        $this->throw404IfNotFound($entity);
        $csrf = $this->get('security.csrf.token_manager');
        $token = $csrf->getToken('ojs_journal_article_file' . $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_article_file_index', ['articleId' => $entity->getArticle()->getId(), 'journalId' => $journal->getId()]);
    }