Ojs\JournalBundle\Controller\JournalUserController::leaveJournalAction PHP Méthode

leaveJournalAction() public méthode

public leaveJournalAction ( $roleId = null )
    public function leaveJournalAction($roleId = null)
    {
        $user = $this->getUser();
        $journalUser = $this->getDoctrine()->getRepository('OjsJournalBundle:JournalUser')->findOneBy(['user' => $user]);
        $this->throw404IfNotFound($journalUser);
        $em = $this->getDoctrine()->getManager();
        if ($roleId === null) {
            $em->remove($journalUser);
            $em->flush();
        } elseif ($journalUser->getRoles()) {
            $role = $this->getDoctrine()->getRepository('OjsUserBundle:Role')->find($roleId);
            $journalUser->getRoles()->removeElement($role);
            $em->persist($journalUser);
            $em->flush();
        }
        return $this->redirect($this->generateUrl('ojs_journal_user_my'));
    }