oauth2-server/examples/relational/Storage/ScopeStorage.php

31 lines
792 B
PHP
Raw Normal View History

2014-05-09 15:16:59 +05:30
<?php
namespace RelationalExample\Storage;
use League\OAuth2\Server\Storage\ScopeInterface;
use League\OAuth2\Server\Storage\Adapter;
2014-06-23 12:50:34 +05:30
use League\OAuth2\Server\Entity\ScopeEntity;
use Illuminate\Database\Capsule\Manager as Capsule;
2014-05-09 15:16:59 +05:30
class ScopeStorage extends Adapter implements ScopeInterface
{
/**
* {@inheritdoc}
*/
public function get($scope, $grantType = null)
{
2014-06-23 12:50:34 +05:30
$result = Capsule::table('oauth_scopes')
->where('id', $scope)
->get();
if (count($result) === 0) {
return null;
}
return (new ScopeEntity($this->server))
->setId($result[0]['id'])
->setDescription($result[0]['description']);
2014-05-09 15:16:59 +05:30
}
}