public function deleteAction(Request $request, $id, $articleId)
{
$em = $this->getDoctrine()->getManager();
$journal = $this->get('ojs.journal_service')->getSelectedJournal();
$article = $em->getRepository('OjsJournalBundle:Article')->find($articleId);
$articleAuthor = $em->getRepository('OjsJournalBundle:ArticleAuthor')->find($id);
if (!$this->isGranted('DELETE', $journal, 'articles')) {
throw new AccessDeniedException("You not authorized for this page!");
}
if (is_null($article) || $articleAuthor == null || $articleAuthor->getArticle()->getId() !== $article->getId()) {
$this->throw404IfNotFound($articleAuthor);
}
$csrf = $this->get('security.csrf.token_manager');
$token = $csrf->getToken('ojs_journal_article_author' . $articleAuthor->getId());
if ($token != $request->get('_token')) {
throw new TokenNotFoundException("Token Not Found!");
}
$this->get('ojs_core.delete.service')->check($articleAuthor);
$em->remove($articleAuthor);
$em->flush();
$this->successFlashBag('successful.remove');
return $this->redirectToRoute('ojs_journal_article_author_index', ['articleId' => $article->getId(), 'journalId' => $journal->getId()]);
}