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 03:13:42 +05:30
|
|
|
/** @var OauthScope|null $row */
|
|
|
|
$row = OauthScope::findOne($scope);
|
2016-02-14 23:20:10 +05:30
|
|
|
if ($row === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$entity = new ScopeEntity($this->server);
|
2016-11-27 03:13:42 +05:30
|
|
|
$entity->setId($row->id);
|
2016-02-14 23:20:10 +05:30
|
|
|
|
|
|
|
return $entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|