getCurrentSession() public method

Returns the currently active session which stores session data for the current HTTP request on this local system.
public getCurrentSession ( ) : Neos\Flow\Session\SessionInterface
return Neos\Flow\Session\SessionInterface
Exemplo n.º 1
0
 /**
  * Merges the session and manager tokens. All manager tokens types will be in the result array
  * If a specific type is found in the session this token replaces the one (of the same type)
  * given by the manager.
  *
  * @param array $managerTokens Array of tokens provided by the authentication manager
  * @param array $sessionTokens Array of tokens restored from the session
  * @return array Array of Authentication\TokenInterface objects
  */
 protected function mergeTokens($managerTokens, $sessionTokens)
 {
     $resultTokens = [];
     if (!is_array($managerTokens)) {
         return $resultTokens;
     }
     /** @var $managerToken TokenInterface */
     foreach ($managerTokens as $managerToken) {
         $noCorrespondingSessionTokenFound = true;
         if (!is_array($sessionTokens)) {
             continue;
         }
         /** @var $sessionToken TokenInterface */
         foreach ($sessionTokens as $sessionToken) {
             if ($sessionToken->getAuthenticationProviderName() === $managerToken->getAuthenticationProviderName()) {
                 $session = $this->sessionManager->getCurrentSession();
                 $this->securityLogger->log(sprintf('Session %s contains auth token %s for provider %s. Status: %s', $session->getId(), get_class($sessionToken), $sessionToken->getAuthenticationProviderName(), $this->tokenStatusLabels[$sessionToken->getAuthenticationStatus()]), LOG_INFO, null, 'Flow');
                 $resultTokens[$sessionToken->getAuthenticationProviderName()] = $sessionToken;
                 $noCorrespondingSessionTokenFound = false;
             }
         }
         if ($noCorrespondingSessionTokenFound) {
             $resultTokens[$managerToken->getAuthenticationProviderName()] = $managerToken;
         }
     }
     return $resultTokens;
 }