Ojs\JournalBundle\Controller\JournalUserController::updateUserAction PHP 메소드

updateUserAction() 공개 메소드

public updateUserAction ( Request $request, $id )
$request Symfony\Component\HttpFoundation\Request
    public function updateUserAction(Request $request, $id)
    {
        $journal = $this->get('ojs.journal_service')->getSelectedJournal();
        $eventDispatcher = $this->get('event_dispatcher');
        $em = $this->getDoctrine()->getManager();
        if (!$this->isGranted('EDIT', $journal, 'userRole')) {
            throw new AccessDeniedException("You not authorized to remove this user from the journal.");
        }
        /** @var JournalUser $entity */
        $entity = $em->getRepository('OjsJournalBundle:JournalUser')->find($id);
        $editForm = $this->createEditForm($entity);
        $editForm->handleRequest($request);
        if ($editForm->isValid()) {
            $event = new JournalItemEvent($entity);
            $eventDispatcher->dispatch(JournalUserEvents::PRE_UPDATE, $event);
            $em->persist($event->getItem());
            $em->flush();
            $event = new JournalItemEvent($event->getItem());
            $eventDispatcher->dispatch(JournalUserEvents::POST_UPDATE, $event);
            if ($event->getResponse()) {
                return $event->getResponse();
            }
            $this->successFlashBag('successful.update');
            return $this->redirectToRoute('ojs_journal_user_index', ['journalId' => $journal->getId()]);
        }
        $this->errorFlashBag('error');
        return $this->redirectToRoute('ojs_journal_user_edit', ['journalId' => $journal->getId(), 'id' => $entity->getId()]);
    }