You are here

public function Scope::getDefaultScope in OAuth2 Server 7

File

lib/Drupal/oauth2_server/Scope.php, line 80

Class

Scope
Provides a scope-checking utility to the library.

Namespace

Drupal\oauth2_server

Code

public function getDefaultScope($client_id = NULL) {

  // Allow any hook_oauth2_server_default_scope() implementations to supply
  // the default scope. The first one to return a scope wins.
  foreach (module_implements('oauth2_server_default_scope') as $module) {
    $function = $module . '_' . 'oauth2_server_default_scope';
    $args = array(
      $this->server,
    );
    $result = call_user_func_array($function, $args);
    if (is_array($result)) {
      return implode(' ', $result);
    }
  }

  // If there's a valid default scope set in server settings, return it.
  $default_scope = $this->server->settings['default_scope'];
  if (!empty($default_scope) && oauth2_server_scope_load($this->server->name, $default_scope)) {
    return $default_scope;
  }
  return FALSE;
}