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