private function OAuth2Storage::setScopeData in OAuth2 Server 8
Same name and namespace in other branches
- 2.0.x src/OAuth2Storage.php \Drupal\oauth2_server\OAuth2Storage::setScopeData()
Sets the "scopes" entityreference field on the passed entity.
Parameters
object $entity: The entity containing the "scopes" entityreference field.
object $server: The machine name of the server.
string $scope: Scopes in a space-separated string.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
3 calls to OAuth2Storage::setScopeData()
- OAuth2Storage::setAccessToken in src/
OAuth2Storage.php - Set access token.
- OAuth2Storage::setAuthorizationCode in src/
OAuth2Storage.php - Set authorization code.
- OAuth2Storage::setRefreshToken in src/
OAuth2Storage.php - Set refresh token.
File
- src/
OAuth2Storage.php, line 922
Class
- OAuth2Storage
- Provides Drupal OAuth2 storage for the library.
Namespace
Drupal\oauth2_serverCode
private function setScopeData($entity, $server, $scope) {
$entity->scopes = [];
if ($scope) {
$scopes = preg_split('/\\s+/', $scope);
/** @var \Drupal\oauth2_server\ScopeInterface[] $loaded_scopes */
$loaded_scopes = $this->entityTypeManager
->getStorage('oauth2_server_scope')
->loadByProperties([
'server_id' => $server
->id(),
'scope_id' => $scopes,
]);
ksort($loaded_scopes);
foreach ($loaded_scopes as $loaded_scope) {
$entity->scopes[] = $loaded_scope
->id();
}
}
}