You are here

function gauth_google_services_scopes in Google Auth 8

Same name and namespace in other branches
  1. 7.2 gauth.module \gauth_google_services_scopes()
  2. 7 gauth.module \gauth_google_services_scopes()

Returns a array services api versions.

1 call to gauth_google_services_scopes()
Gauth::getGauthClient in src/Entity/Gauth.php
Function to retrieve the google client for different operations.

File

./gauth.module, line 55
Google Auth Api for drupal.

Code

function gauth_google_services_scopes($services, $by_pass_cache = FALSE) {
  if (!$services) {
    return FALSE;
  }
  if (!is_array($services)) {
    $services = [
      $services,
    ];
  }
  $cache = \Drupal::cache('gauth_scopes')
    ->getMultiple($services);
  if (!$by_pass_cache && !empty($cache)) {
    $scopes = array();
    foreach ($cache as $s => $c) {
      if ($c->data) {
        $scopes[$s] = $c->data;
      }
    }
    return $scopes;
  }
  else {
    \Drupal::cache('gauth_scopes')
      ->deleteAll();
    $services = array_flip($services);
    $scopes = _gauth_read_scope_info();
    return array_intersect_key($scopes, $services);
  }
}