You are here

public function Gauth::getServiceObjects in Google Auth 8

This function is designed to return objects of services classes.

So if the account is authenticated for say Google calendar then this function will return Google_Service_Calendar class object.

Parameters

array $services: Array of services so that objects can be contructed.

Return value

array Array of Google_Service classes with servicename as index.

Throws

\Drupal\Core\Entity\EntityStorageException

File

src/Entity/Gauth.php, line 564

Class

Gauth
Defines the Gauth entity.

Namespace

Drupal\gauth\Entity

Code

public function getServiceObjects(array $services = []) {
  if (empty($services)) {
    $services = $this
      ->getServices();
  }
  if (!is_array($services)) {
    $services = [
      $services,
    ];
  }
  $classes = \Drupal::config('gauth.google_api_classes')
    ->get('gauth_google_api_classes');
  $return = [];
  $client = self::getGauthClient($this);
  foreach ($services as $service) {
    $return[$service] = new $classes[$service]($client);
  }
  return $return;
}