public function deleteAction(Request $request, $id)
{
/** @var JournalFile $entity */
$journal = $this->get('ojs.journal_service')->getSelectedJournal();
$entity = $this->getDoctrine()->getRepository('OjsJournalBundle:JournalFile')->find($id);
$this->throw404IfNotFound($entity);
if (!$this->isGranted('DELETE', $journal, 'files')) {
throw new AccessDeniedException("You are not authorized for this file!");
}
$em = $this->getDoctrine()->getManager();
$csrf = $this->get('security.csrf.token_manager');
$token = $csrf->getToken('ojs_journal_filemanager' . $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_filemanager_index', ['journalId' => $journal->getId()]);
}