Ojs\AdminBundle\Controller\AdminJournalController::updateAction PHP Method

updateAction() public method

Edits an existing Journal entity.
public updateAction ( Request $request, $id ) : RedirectResponse | Response
$request Symfony\Component\HttpFoundation\Request
$id
return Symfony\Component\HttpFoundation\RedirectResponse | Symfony\Component\HttpFoundation\Response
    public function updateAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();
        /** @var Journal $entity */
        $entity = $em->getRepository('OjsJournalBundle:Journal')->find($id);
        $this->throw404IfNotFound($entity);
        /** @var $dispatcher EventDispatcherInterface */
        $dispatcher = $this->get('event_dispatcher');
        $editForm = $this->createEditForm($entity);
        $editForm->handleRequest($request);
        if ($editForm->isValid()) {
            $em->persist($entity);
            $em->flush();
            $this->successFlashBag('successful.update');
            $event = new AdminEvent(['eventType' => 'update', 'entity' => $entity]);
            $dispatcher->dispatch(AdminEvents::ADMIN_JOURNAL_CHANGE, $event);
            return $this->redirectToRoute('ojs_admin_journal_edit', ['id' => $id]);
        }
        return $this->render('OjsAdminBundle:AdminJournal:edit.html.twig', array('entity' => $entity, 'edit_form' => $editForm->createView()));
    }