2016-02-14 23:20:10 +05:30
|
|
|
<?php
|
2016-11-27 03:13:42 +05:30
|
|
|
namespace api\components\OAuth2\Storage;
|
2016-02-14 23:20:10 +05:30
|
|
|
|
2016-11-27 03:13:42 +05:30
|
|
|
use api\components\OAuth2\Entities\ScopeEntity;
|
2016-02-14 23:20:10 +05:30
|
|
|
use common\models\OauthScope;
|
|
|
|
use League\OAuth2\Server\Storage\AbstractStorage;
|
|
|
|
use League\OAuth2\Server\Storage\ScopeInterface;
|
|
|
|
|
|
|
|
class ScopeStorage extends AbstractStorage implements ScopeInterface {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function get($scope, $grantType = null, $clientId = null) {
|
2016-11-27 21:49:13 +05:30
|
|
|
if (!in_array($scope, OauthScope::getScopes(), true)) {
|
2016-02-14 23:20:10 +05:30
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$entity = new ScopeEntity($this->server);
|
2016-11-27 21:49:13 +05:30
|
|
|
$entity->setId($scope);
|
2016-02-14 23:20:10 +05:30
|
|
|
|
|
|
|
return $entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|