public function updateJournalAction(Request $request)
{
$eventDispatcher = $this->get('event_dispatcher');
$em = $this->getDoctrine()->getManager();
$entity = $this->get('ojs.journal_service')->getSelectedJournal(false);
$this->throw404IfNotFound($entity);
if (!$this->isGranted('EDIT', $entity)) {
throw new AccessDeniedException("You are not authorized for this page!");
}
$editForm = $this->createJournalEditForm($entity);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$entity->setLanguageCodeSet($entity->getLanguages());
$entity->addLanguage($entity->getMandatoryLang());
$event = new JournalEvent($entity);
$eventDispatcher->dispatch(JournalEvents::PRE_UPDATE, $event);
$em->persist($event->getJournal());
$em->flush();
$event = new JournalEvent($event->getJournal());
$eventDispatcher->dispatch(JournalEvents::POST_UPDATE, $event);
if ($event->getResponse()) {
return $event->getResponse();
}
$this->successFlashBag('successful.update');
return $this->redirectToRoute('ojs_journal_settings_index', ['journalId' => $entity->getId()]);
}
return $this->render('OjsJournalBundle:Manager:journal_settings.html.twig', array('entity' => $entity, 'edit_form' => $editForm->createView()));
}