Exemple #1
0
 public function onKernelRequest(GetResponseEvent $event)
 {
     $this->request = $event->getRequest();
     $this->session = $event->getRequest()->getSession();
     if ($event->isMasterRequest()) {
         $this->journalService->setSelectedJournal();
         $this->loadClientUsers();
     }
 }
Exemple #2
0
 /**
  * @return bool|Journal
  */
 public function selectedJournal()
 {
     try {
         return $this->journalService->getSelectedJournal();
     } catch (\Exception $e) {
         return false;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getSecurityIdentities(Token\TokenInterface $token)
 {
     $sids = array();
     // add user security identity
     if (!$token instanceof Token\AnonymousToken) {
         try {
             $sids[] = UserSecurityIdentity::fromToken($token);
         } catch (\InvalidArgumentException $invalid) {
             // ignore, user has no user security identity
         }
     }
     // add all reachable roles
     foreach ($this->roleHierarchy->getReachableRoles($token->getRoles()) as $role) {
         $sids[] = new RoleSecurityIdentity($role);
     }
     // add journal roles
     $user = $token->getUser();
     try {
         $selectedJournal = $this->journalService->getSelectedJournal();
     } catch (\Exception $e) {
         $selectedJournal = false;
     }
     if ($user instanceof User && $selectedJournal instanceof Journal) {
         foreach ($user->getJournalRoles($selectedJournal) as $journalRoles) {
             $sids[] = new JournalRoleSecurityIdentity($journalRoles[0], $journalRoles[1]);
         }
     }
     // add built-in special roles
     if ($this->authenticationTrustResolver->isFullFledged($token)) {
         $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_FULLY);
         $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED);
         $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY);
     } elseif ($this->authenticationTrustResolver->isRememberMe($token)) {
         $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED);
         $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY);
     } elseif ($this->authenticationTrustResolver->isAnonymous($token)) {
         $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY);
     }
     return $sids;
 }
Exemple #4
0
 /**
  *
  * @param  Article $article
  * @return string
  */
 public function generateUrl(Article $article)
 {
     $journalUrl = $this->journalService->generateUrl($article->getJournal());
     return $journalUrl . '/' . $article->getSlug();
 }