public function updateAction(Request $request, $id)
{
$journal = $this->get('ojs.journal_service')->getSelectedJournal();
$eventDispatcher = $this->get('event_dispatcher');
if (!$this->isGranted('EDIT', $journal, 'issues')) {
throw new AccessDeniedException("You are not authorized for edit this journal's issue!");
}
$em = $this->getDoctrine()->getManager();
/** @var Issue $entity */
$entity = $em->getRepository('OjsJournalBundle:Issue')->find($id);
$this->throw404IfNotFound($entity);
$editForm = $this->createEditForm($entity, $journal->getId());
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$event = new JournalItemEvent($entity);
$eventDispatcher->dispatch(IssueEvents::PRE_UPDATE, $event);
$em->persist($event->getItem());
$em->flush();
$event = new JournalItemEvent($event->getItem());
$eventDispatcher->dispatch(IssueEvents::POST_UPDATE, $event);
if ($event->getResponse()) {
return $event->getResponse();
}
$this->successFlashBag('successful.update');
return $this->redirectToRoute('ojs_journal_issue_edit', ['journalId' => $entity->getJournal()->getId(), 'id' => $id]);
}
return $this->render('OjsJournalBundle:Issue:edit.html.twig', array('entity' => $entity, 'edit_form' => $editForm->createView()));
}