芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/shimoda/lib/Storage/ApiScopeStorage.php
. */ namespace Xibo\Storage; use League\OAuth2\Server\Entity\ScopeEntity; use League\OAuth2\Server\Storage\AbstractStorage; use League\OAuth2\Server\Storage\ScopeInterface; class ApiScopeStorage extends AbstractStorage implements ScopeInterface { /** * @var StorageServiceInterface */ private $store; /** * ApiAccessTokenStorage constructor. * @param StorageServiceInterface $store */ public function __construct($store) { if (!$store instanceof StorageServiceInterface) throw new \RuntimeException('Invalid $store'); $this->store = $store; } /** * Get Store * @return StorageServiceInterface */ protected function getStore() { return $this->store; } /** * {@inheritdoc} */ public function get($scope, $grantType = null, $clientId = null) { $result = $this->getStore()->select('SELECT * FROM oauth_scopes WHERE id = :id ', array('id' => $scope)); if (count($result) === 0) { return; } if ($clientId !== null) { // Check to see if this scope exists for this client $clientScope = $this->getStore()->select('SELECT * FROM `oauth_client_scopes` WHERE clientId = :clientId AND scopeId = :id', [ 'clientId' => $clientId, 'id' => $scope ]); if (count($clientScope) == 0) return; } return (new ScopeEntity($this->server))->hydrate([ 'id' => $result[0]['id'], 'description' => $result[0]['description'], ]); } }