32 lines
796 B
PHP
Raw Normal View History

2014-05-09 10:46:59 +01:00
<?php
namespace RelationalExample\Storage;
use League\OAuth2\Server\Storage\ScopeInterface;
use League\OAuth2\Server\Storage\Adapter;
2014-06-23 08:20:34 +01:00
use League\OAuth2\Server\Entity\ScopeEntity;
use Illuminate\Database\Capsule\Manager as Capsule;
2014-05-09 10:46:59 +01:00
class ScopeStorage extends Adapter implements ScopeInterface
{
/**
* {@inheritdoc}
*/
public function get($scope, $grantType = null)
{
2014-06-23 08:20:34 +01:00
$result = Capsule::table('oauth_scopes')
->where('id', $scope)
->get();
if (count($result) === 0) {
return null;
}
2014-07-11 18:27:03 +01:00
return (new ScopeEntity($this->server))->hydrate([
'id' => $result[0]['id'],
'description' => $result[0]['description']
]);
2014-05-09 10:46:59 +01:00
}
}