public function __construct(ServiceLocatorInterface $serviceLocator) { $request = new Request(); if (is_null($this->userLogged)) { if ($request->getHeader('Authorization') == '') { $sessionStorage = new SessionStorage("SessaoUsuario"); $this->authService = new AuthenticationService(); $this->authService->setStorage($sessionStorage); if ($this->getAuthService()->hasIdentity()) { $this->userLogged = $this->getAuthService()->getIdentity(); } else { return FALSE; } } else { $this->authApiService = $serviceLocator->get('api-identity'); if ($this->authApiService->getAuthenticationIdentity()) { /** @var \Doctrine\ORM\EntityManager $entityManager */ $entityManager = $serviceLocator->get("Doctrine\\ORM\\EntityManager"); $userEntity = $entityManager->getRepository("Application\\Entity\\WcUser")->findOneByUsername($this->authApiService->getAuthenticationIdentity()['user_id']); /** @var \Auth\Service\AuthService $authService */ $authService = $serviceLocator->get("Auth\\Service\\AuthService"); $getArraySession = $authService->getArraySession($userEntity); $this->userLogged = $getArraySession; } else { return FALSE; } } } return $this->userLogged; }