public function createAction(Request $request)
{
$journal = $this->get('ojs.journal_service')->getSelectedJournal();
if (!$this->isGranted('CREATE', $journal, 'files')) {
throw new AccessDeniedException("You are not authorized for this file!");
}
$entity = new JournalFile();
$form = $this->createCreateForm($entity);
$form->handleRequest($request);
if ($form->isValid()) {
$rootDir = $this->getParameter('kernel.root_dir');
$path = $rootDir . '/../web/uploads/files/' . $entity->getPath();
$entity->setSize(StringHelper::formatBytes(filesize($path)));
$entity->setJournal($journal);
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
$this->successFlashBag('successful.create');
return $this->redirectToRoute('ojs_journal_filemanager_show', ['id' => $entity->getId(), 'journalId' => $journal->getId()]);
}
return $this->render('OjsJournalBundle:JournalFile:new.html.twig', ['entity' => $entity, 'form' => $form->createView()]);
}