/** * @param ServiceLocatorInterface $controllers * @return AuthController */ public function createService(ServiceLocatorInterface $controllers) { $services = $controllers->getServiceLocator()->get('ServiceManager'); // For BC, if the ZF\OAuth2\Service\OAuth2Server service returns an // OAuth2\Server instance, wrap it in a closure. $oauth2ServerFactory = $services->get('ZF\\OAuth2\\Service\\OAuth2Server'); if ($oauth2ServerFactory instanceof OAuth2Server) { $oauth2Server = $oauth2ServerFactory; $oauth2ServerFactory = function () use($oauth2Server) { return $oauth2Server; }; } $authController = new AuthController($oauth2ServerFactory, $services->get('ZF\\OAuth2\\Provider\\UserId')); $config = $services->get('Config'); $authController->setApiProblemErrorResponse(isset($config['zf-oauth2']['api_problem_error_response']) && $config['zf-oauth2']['api_problem_error_response'] === true); return $authController; }
/** * @param ContainerInterface $container * @param string $requestedName * @param null|array $options * @return AuthController */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $authController = new AuthController($this->getOAuth2ServerFactory($container), $container->get(UserId::class)); $authController->setApiProblemErrorResponse($this->marshalApiProblemErrorResponse($container)); return $authController; }