3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Mvc\Controller\Plugin\Service
;
12 use Interop\Container\ContainerInterface
;
13 use Zend\Authentication\AuthenticationService
;
14 use Zend\Mvc\Controller\Plugin\Identity
;
15 use Zend\ServiceManager\FactoryInterface
;
16 use Zend\ServiceManager\ServiceLocatorInterface
;
18 class IdentityFactory
implements FactoryInterface
25 public function __invoke(ContainerInterface
$container, $name, array $options = null)
27 $helper = new Identity();
28 if ($container->has(AuthenticationService
::class)) {
29 $helper->setAuthenticationService($container->get(AuthenticationService
::class));
35 * Create and return Identity instance
37 * For use with zend-servicemanager v2; proxies to __invoke().
39 * @param ServiceLocatorInterface $container
42 public function createService(ServiceLocatorInterface
$container)
44 // Retrieve the parent container when under zend-servicemanager v2
45 if (! method_exists($container, 'configure')) {
46 $container = $container->getServiceLocator() ?
: $container;
49 return $this($container, Identity
::class);