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