Added PasswordGrantProvider

This commit is contained in:
Alex Bilbie 2015-04-05 21:12:26 +01:00
parent b5bbf8332f
commit d3ed454881

View File

@ -0,0 +1,37 @@
<?php
namespace League\OAuth2\Server\ServiceProviders;
use League\Container\ServiceProvider;
use League\OAuth2\Server\Grant\PasswordGrant;
class PasswordGrantProvider extends ServiceProvider
{
protected $provides = ['PasswordGrant'];
/**
* @inheritdoc
*/
public function register()
{
$container = $this->getContainer();
$container->add('PasswordGrant', function () use ($container) {
$refreshTokenRepository = null;
if ($container->isRegistered('RefreshTokenRepository')) {
$refreshTokenRepository = $container->get('RefreshTokenRepository');
}
$grant = new PasswordGrant(
$container->get('emitter'),
$container->get('ClientRepository'),
$container->get('ScopeRepository'),
$container->get('AccessTokenRepository'),
$container->get('UserRepository'),
$refreshTokenRepository
);
return $grant;
});
}
}