public function getIdentity() { $identity = parent::getIdentity(); if ($identity !== null && $identity->getId() == 'Facilis\\Users\\UserAggregate' && $identity instanceof Identity) { $identity = $this->entityManager->getRepository('Facilis\\Users\\UserAggregate')->find($identity->getData()['id']); } return $identity; }
function __construct(ObjectRepository $userRepository, Session $sessionHandler) { parent::__construct($sessionHandler); $identity = parent::getIdentity(); if ($identity !== NULL) { $identity = $userRepository->find($identity->getId()); } $this->identity = $identity; }
/** * Returns current user identity, if any. * @return IIdentity|NULL */ public function getIdentity() { $identity = parent::getIdentity(); // if we have our fake identity, we now want to // convert it back into the real entity // returning reference provides potentially lazy behavior if ($identity instanceof FakeIdentity) { return $this->entityManager->getReference($identity->getClass(), $identity->getId()); } return $identity; }
/** * @return Identity|Nette\Security\IIdentity|NULL * @throws InvalidStateException */ public function getIdentity() { $identity = parent::getIdentity(); if ($this->users === NULL) { throw new InvalidStateException('Service IUsers is not registered.'); } if ($identity instanceof Identity && !$identity->isLoaded()) { $this->users->loadIdentity($identity); } return $identity; }
/** * Returns current user identity, if any. * @return User|NULL */ public function getIdentity() { if ($this->identity) { return $this->identity; } $identity = parent::getIdentity(); if ($identity instanceof FakeIdentity) { $this->identity = $this->userRepository->get($identity->getId()); return $this->identity; } return $identity; }
public function getIdentity() { $identity = parent::getIdentity(); if (!$identity instanceof Identity) { return $identity; } if (!$this->checkConnection->invoke()) { return NULL; } if (!isset($this->identities[$identity->id])) { $this->identities[$identity->id] = $this->userRepository->findOneBy(array('id' => $identity->id, 'published' => 1)); } return $this->identities[$identity->id]; }
/** * Returns current user identity, if any. * @return IIdentity|NULL */ public function getIdentity() { $identity = parent::getIdentity(); // if we have our fake identity, we now want to // convert it back into the real entity if ($identity instanceof FakeIdentity) { return $this->cache->load(sprintf('user-%s', $identity->getId()), function () use($identity) { return $this->entityManager->createQuery('SELECT u, roles FROM ' . $identity->getClass() . ' u LEFT JOIN u.roles roles WHERE u.id = :id')->setParameter('id', $identity->getId())->getOneOrNullResult(); }); //return $this->entityManager->getReference($identity->getClass(), $identity->getId()); } return $identity; }