authenticationService; } /** * @param AuthenticationServiceInterface $authenticationService */ public function setAuthenticationService(AuthenticationServiceInterface $authenticationService) { $this->authenticationService = $authenticationService; } /** * Retrieve the current identity, if any. * * If none is present, returns null. * * @return mixed|null * @throws Exception\RuntimeException */ public function __invoke() { if (!$this->authenticationService instanceof AuthenticationServiceInterface) { throw new Exception\RuntimeException('No AuthenticationServiceInterface instance provided'); } if (!$this->authenticationService->hasIdentity()) { return; } return $this->authenticationService->getIdentity(); } }