You are here

private function Storage::setScopeData in OAuth2 Server 7

Sets the "scopes" entityreference field on the passed entity.

Parameters

$entity: The entity containing the "scopes" entityreference field.

$server: The machine name of the server.

$scope: Scopes in a space-separated string.

3 calls to Storage::setScopeData()
Storage::setAccessToken in lib/Drupal/oauth2_server/Storage.php
Storage::setAuthorizationCode in lib/Drupal/oauth2_server/Storage.php
Storage::setRefreshToken in lib/Drupal/oauth2_server/Storage.php

File

lib/Drupal/oauth2_server/Storage.php, line 454

Class

Storage
Provides Drupal storage (through the underlying Entity API) for the library.

Namespace

Drupal\oauth2_server

Code

private function setScopeData($entity, $server, $scope) {
  $entity->scopes = array();
  if ($scope) {
    $scopes = preg_split('/\\s+/', $scope);
    $loaded_scopes = oauth2_server_scope_load_multiple($server, $scopes);
    foreach ($loaded_scopes as $loaded_scope) {
      $entity->scopes[LANGUAGE_NONE][] = array(
        'target_id' => $loaded_scope->scope_id,
      );
    }
  }
}