src/Factory/DefaultAuthenticationListenerFactory.php
/**
     * Create an OAuth2 server by introspecting the config service
     *
     * @param ContainerInterface $container
     * @return false|OAuth2Adapter
     */
Create an OAuth2 server by introspecting the config service
@param ContainerInterface $container
@return false|OAuth2Adapter
Create an OAuth2 server by introspecting the config service @param ContainerInterface $container @return false|OAuth2Adapter
protected function createOAuth2Server(ContainerInterface $container)
    {
        if (! $container->has('config')) {
            return false;
        }
        $config = $container->get('config');
        if (! isset($config['api-tools-oauth2']['storage'])
            || ! is_string($config['api-tools-oauth2']['storage'])
            || ! $container->has($config['api-tools-oauth2']['storage'])
        ) {
            return false;
        }
        if ($container->has('Laminas\ApiTools\OAuth2\Service\OAuth2Server')) {
            $factory = $container->get('Laminas\ApiTools\OAuth2\Service\OAuth2Server');
            return new OAuth2Adapter($factory());
        }
        $factory = new LaminasOAuth2ServerFactory();
        try {
            $serverFactory = $factory($container);
        } catch (RuntimeException $e) {
            switch (true) {
                case strpos($e->getMessage(), 'missing'):
                    return false;
                case strpos($e->getMessage(), 'string or array'):
                    return false;
                default:
                    throw $e;
            }
        }
        return new OAuth2Adapter($serverFactory(null));
    }
protected function createOAuth2Server ( ContainerInterface $ container ) { if ( ! $ container -> has ( 'config' ) ) { return false ; } $ config = $ container -> get ( 'config' ) ; if ( ! isset ( $ config [ 'api-tools-oauth2' ] [ 'storage' ] ) || ! is_string ( $ config [ 'api-tools-oauth2' ] [ 'storage' ] ) || ! $ container -> has ( $ config [ 'api-tools-oauth2' ] [ 'storage' ] ) ) { return false ; } if ( $ container -> has ( 'Laminas\ApiTools\OAuth2\Service\OAuth2Server' ) ) { $ factory = $ container -> get ( 'Laminas\ApiTools\OAuth2\Service\OAuth2Server' ) ; return new OAuth2Adapter ( $ factory ( ) ) ; } $ factory = new LaminasOAuth2ServerFactory ( ) ; try { $ serverFactory = $ factory ( $ container ) ; } catch ( RuntimeException $ e ) { switch ( true ) { case strpos ( $ e -> getMessage ( ) , 'missing' ) : return false ; case strpos ( $ e -> getMessage ( ) , 'string or array' ) : return false ; default : throw $ e ; } } return new OAuth2Adapter ( $ serverFactory ( null ) ) ; }
Create an OAuth2 server by introspecting the config service
 @param ContainerInterface $container
 @return false|OAuth2Adapter
Create an OAuth2 server by introspecting the config service @param ContainerInterface $container @return false|OAuth2Adapter
// If we don't have configuration, we cannot create an OAuth2 server. // If the service locator already has a pre-configured OAuth2 server, use it. // These are exceptions specifically thrown from the // Laminas\ApiTools\OAuth2\Factory\OAuth2ServerFactory when essential // configuration is missing. // Any other RuntimeException at this point we don't know // about and need to re-throw.