public function updateAction(Request $request, Article $article)
{
$journal = $this->get('ojs.journal_service')->getSelectedJournal();
$em = $this->getDoctrine()->getManager();
if (!$this->isGranted('EDIT', $journal, 'articles')) {
throw new AccessDeniedException("You not authorized for this page!");
}
$dispatcher = $this->get('event_dispatcher');
$editForm = $this->createEditForm($article, $journal)->add('update', 'submit', array('label' => 'u'));
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$event = new JournalItemEvent($article);
$dispatcher->dispatch(ArticleEvents::PRE_UPDATE, $event);
$em->persist($event->getItem());
$em->flush();
$this->successFlashBag('successful.update');
$event = new JournalItemEvent($event->getItem());
$dispatcher->dispatch(ArticleEvents::POST_UPDATE, $event);
if ($event->getResponse()) {
return $event->getResponse();
}
return $this->redirect($this->generateUrl('ojs_journal_article_edit', array('id' => $event->getItem()->getId(), 'journalId' => $journal->getId())));
}
return $this->render('OjsJournalBundle:Article:edit.html.twig', ['entity' => $article, 'form' => $editForm->createView()]);
}