/** * Create service * * @param ServiceLocatorInterface $serviceLocator * @return AuthenticationService */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $this->getConfig($serviceLocator); $authService = new AuthenticationService(); $sessionStorageConfig = ['namespace' => __NAMESPACE__, 'member' => null]; if (isset($config['session_storage']) && is_array($config['session_storage'])) { $sessionStorageConfig = array_merge($sessionStorageConfig, $config['session_storage']); } /** @var $sessionManager SessionManager */ $sessionManager = $serviceLocator->get('Zend\\Session\\SessionManager'); $authService->setStorage(new Session($sessionStorageConfig['namespace'], $sessionStorageConfig['member'], $sessionManager)); if (isset($config['adapter']) && is_string($config['adapter']) && $serviceLocator->has($config['adapter'])) { /** @var $adapter AdapterInterface */ $adapter = $serviceLocator->get($config['adapter']); $authService->setAdapter($adapter); } return $authService; }