diff --git a/psalm-baseline.xml b/psalm-baseline.xml index fd903ff..baeb869 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -155,6 +155,9 @@ + + AuthControllerFactory + $container->get(UserId::class) UserId::class @@ -171,6 +174,9 @@ $oauth2ServerFactory + + $controllers + UserId diff --git a/src/Factory/AuthControllerFactory.php b/src/Factory/AuthControllerFactory.php index 4354190..c81a690 100644 --- a/src/Factory/AuthControllerFactory.php +++ b/src/Factory/AuthControllerFactory.php @@ -6,10 +6,12 @@ use Laminas\ApiTools\OAuth2\Controller\AuthController; use Laminas\ApiTools\OAuth2\Provider\UserId; +use Laminas\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; use OAuth2\Server as OAuth2Server; use Psr\Container\ContainerInterface; -class AuthControllerFactory +class AuthControllerFactory implements FactoryInterface { /** * @param string $requestedName @@ -30,6 +32,18 @@ public function __invoke(ContainerInterface $container, $requestedName, ?array $ return $authController; } + /** + * @param null|string $name + * @param null|string $requestedName + * @return AuthController + */ + public function createService(ServiceLocatorInterface $controllers, $name = null, $requestedName = null) + { + $requestedName = $requestedName ?: AuthController::class; + + return $this($controllers, $requestedName); + } + /** * Retrieve the OAuth2\Server factory. * diff --git a/src/Factory/MongoAdapterFactory.php b/src/Factory/MongoAdapterFactory.php index 953780e..c8dffba 100644 --- a/src/Factory/MongoAdapterFactory.php +++ b/src/Factory/MongoAdapterFactory.php @@ -7,6 +7,7 @@ use ArrayAccess; use Laminas\ApiTools\OAuth2\Adapter\MongoAdapter; use Laminas\ApiTools\OAuth2\Controller\Exception; +use Laminas\ServiceManager\ServiceLocatorInterface; use MongoClient; use MongoDB; use Psr\Container\ContainerInterface; @@ -27,6 +28,17 @@ public function __invoke(ContainerInterface $container) ); } + /** + * Provided for backwards compatibility; proxies to __invoke(). + * + * @param ServiceLocatorInterface $container + * @return MongoAdapter + */ + public function createService($container) + { + return $this($container); + } + /** * Get the mongo database * diff --git a/src/Factory/OAuth2ServerFactory.php b/src/Factory/OAuth2ServerFactory.php index 551552c..b6c6ba8 100644 --- a/src/Factory/OAuth2ServerFactory.php +++ b/src/Factory/OAuth2ServerFactory.php @@ -4,6 +4,7 @@ namespace Laminas\ApiTools\OAuth2\Factory; +use Laminas\ServiceManager\ServiceLocatorInterface; use Psr\Container\ContainerInterface; class OAuth2ServerFactory @@ -17,4 +18,15 @@ public function __invoke(ContainerInterface $container) $config = $config['api-tools-oauth2'] ?? []; return new OAuth2ServerInstanceFactory($config, $container); } + + /** + * Provided for backwards compatibility; proxies to __invoke(). + * + * @param ServiceLocatorInterface $container + * @return OAuth2ServerInstanceFactory + */ + public function createService($container) + { + return $this($container); + } } diff --git a/src/Factory/PdoAdapterFactory.php b/src/Factory/PdoAdapterFactory.php index 774b7f2..80052e4 100644 --- a/src/Factory/PdoAdapterFactory.php +++ b/src/Factory/PdoAdapterFactory.php @@ -6,6 +6,7 @@ use Laminas\ApiTools\OAuth2\Adapter\PdoAdapter; use Laminas\ApiTools\OAuth2\Controller\Exception; +use Laminas\ServiceManager\ServiceLocatorInterface; use Psr\Container\ContainerInterface; use function is_array; @@ -43,4 +44,15 @@ public function __invoke(ContainerInterface $container) 'options' => $options, ], $oauth2ServerConfig); } + + /** + * Provided for backwards compatibility; proxies to __invoke(). + * + * @param ServiceLocatorInterface $container + * @return PdoAdapter + */ + public function createService($container) + { + return $this($container); + } } diff --git a/src/Provider/UserId/AuthenticationServiceFactory.php b/src/Provider/UserId/AuthenticationServiceFactory.php index d8536f3..98aee5d 100644 --- a/src/Provider/UserId/AuthenticationServiceFactory.php +++ b/src/Provider/UserId/AuthenticationServiceFactory.php @@ -4,6 +4,7 @@ namespace Laminas\ApiTools\OAuth2\Provider\UserId; +use Laminas\ServiceManager\ServiceLocatorInterface; use Psr\Container\ContainerInterface; class AuthenticationServiceFactory @@ -24,4 +25,15 @@ public function __invoke(ContainerInterface $container) return new AuthenticationService(null, $config); } + + /** + * Provided for backwards compatibility; proxies to __invoke(). + * + * @param ServiceLocatorInterface $container + * @return AuthenticationService + */ + public function createService($container) + { + return $this($container); + } }