Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Witold Wasiczko <witold@wasiczko.pl>
  • Loading branch information
snapshotpl committed Jun 2, 2022
1 parent 4fb040a commit 41b891b
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 1 deletion.
6 changes: 6 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@
</UndefinedMagicMethod>
</file>
<file src="src/Factory/AuthControllerFactory.php">
<DeprecatedInterface occurrences="1">
<code>AuthControllerFactory</code>
</DeprecatedInterface>
<MixedArgument occurrences="2">
<code>$container-&gt;get(UserId::class)</code>
<code>UserId::class</code>
Expand All @@ -171,6 +174,9 @@
<MixedReturnStatement occurrences="1">
<code>$oauth2ServerFactory</code>
</MixedReturnStatement>
<ParamNameMismatch occurrences="1">
<code>$controllers</code>
</ParamNameMismatch>
<UndefinedClass occurrences="1">
<code>UserId</code>
</UndefinedClass>
Expand Down
16 changes: 15 additions & 1 deletion src/Factory/AuthControllerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
*
Expand Down
12 changes: 12 additions & 0 deletions src/Factory/MongoAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
*
Expand Down
12 changes: 12 additions & 0 deletions src/Factory/OAuth2ServerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Laminas\ApiTools\OAuth2\Factory;

use Laminas\ServiceManager\ServiceLocatorInterface;
use Psr\Container\ContainerInterface;

class OAuth2ServerFactory
Expand All @@ -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);
}
}
12 changes: 12 additions & 0 deletions src/Factory/PdoAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
12 changes: 12 additions & 0 deletions src/Provider/UserId/AuthenticationServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Laminas\ApiTools\OAuth2\Provider\UserId;

use Laminas\ServiceManager\ServiceLocatorInterface;
use Psr\Container\ContainerInterface;

class AuthenticationServiceFactory
Expand All @@ -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);
}
}

0 comments on commit 41b891b

Please sign in to comment.