Ojs\JournalBundle\Controller\BoardController::updateAction PHP Метод

updateAction() публичный Метод

Edits an existing Board entity.
public updateAction ( Request $request, Board $entity ) : RedirectResponse | Response
$request Symfony\Component\HttpFoundation\Request
$entity Ojs\JournalBundle\Entity\Board
Результат Symfony\Component\HttpFoundation\RedirectResponse | Symfony\Component\HttpFoundation\Response
    public function updateAction(Request $request, Board $entity)
    {
        $journal = $this->get('ojs.journal_service')->getSelectedJournal();
        $eventDispatcher = $this->get('event_dispatcher');
        if (!$this->isGranted('EDIT', $journal, 'boards')) {
            throw new AccessDeniedException("You not authorized for edit this journal's boards!");
        }
        $em = $this->getDoctrine()->getManager();
        $editForm = $this->createEditForm($entity);
        $editForm->handleRequest($request);
        if ($editForm->isValid()) {
            $event = new JournalItemEvent($entity);
            $eventDispatcher->dispatch(BoardEvents::PRE_UPDATE, $event);
            $em->persist($event->getItem());
            $em->flush();
            $event = new JournalItemEvent($event->getItem());
            $eventDispatcher->dispatch(BoardEvents::POST_UPDATE, $event);
            if ($event->getResponse()) {
                return $event->getResponse();
            }
            $this->successFlashBag('successful.update');
            return $this->redirectToRoute('ojs_journal_board_edit', ['id' => $entity->getId(), 'journalId' => $journal->getId()]);
        }
        return $this->render('OjsJournalBundle:Board:edit.html.twig', array('entity' => $entity, 'edit_form' => $editForm->createView()));
    }