Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Mvc / Controller / Plugin / Identity.php
blob366ed950688170d3ea48c41982dc2652dc9c82cd
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Mvc\Controller\Plugin;
12 use Zend\Authentication\AuthenticationService;
13 use Zend\Mvc\Exception;
15 /**
16 * Controller plugin to fetch the authenticated identity.
18 class Identity extends AbstractPlugin
20 /**
21 * @var AuthenticationService
23 protected $authenticationService;
25 /**
26 * @return AuthenticationService
28 public function getAuthenticationService()
30 return $this->authenticationService;
33 /**
34 * @param AuthenticationService $authenticationService
36 public function setAuthenticationService(AuthenticationService $authenticationService)
38 $this->authenticationService = $authenticationService;
41 /**
42 * Retrieve the current identity, if any.
44 * If none is present, returns null.
46 * @return mixed|null
47 * @throws Exception\RuntimeException
49 public function __invoke()
51 if (!$this->authenticationService instanceof AuthenticationService) {
52 throw new Exception\RuntimeException('No AuthenticationService instance provided');
54 if (!$this->authenticationService->hasIdentity()) {
55 return null;
57 return $this->authenticationService->getIdentity();