public function updateAction(Request $request, Subject $entity)
{
$this->throw404IfNotFound($entity);
/** @var $dispatcher EventDispatcherInterface */
$dispatcher = $this->get('event_dispatcher');
$em = $this->getDoctrine()->getManager();
$editForm = $this->createEditForm($entity);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$entity->setSlug($entity->getTranslationByLocale($request->getDefaultLocale())->getSubject());
$em->flush();
$this->successFlashBag('successful.update');
$event = new AdminEvent(['eventType' => 'update', 'entity' => $entity]);
$dispatcher->dispatch(AdminEvents::ADMIN_SUBJECT_CHANGE, $event);
return $this->redirectToRoute('ojs_admin_subject_edit', ['id' => $entity->getId()]);
}
return $this->render('OjsAdminBundle:AdminSubject:edit.html.twig', array('entity' => $entity, 'edit_form' => $editForm->createView()));
}