You are here

public function GoogleApiClientService::getServiceObjects in Google API PHP Client 8.2

Same name and namespace in other branches
  1. 8.4 src/Service/GoogleApiClientService.php \Drupal\google_api_client\Service\GoogleApiClientService::getServiceObjects()
  2. 8.3 src/Service/GoogleApiClientService.php \Drupal\google_api_client\Service\GoogleApiClientService::getServiceObjects()

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

bool $blank_client: If we should use a blank client object.

bool $return_object: True if we want objects else classes returned.

Return value

array Array of Google_Service classes with servicename as index.

File

src/Service/GoogleApiClientService.php, line 208

Class

GoogleApiClientService
Class Google API Client Service.

Namespace

Drupal\google_api_client\Service

Code

public function getServiceObjects($blank_client = FALSE, $return_object = TRUE) {
  $google_api_client = $this->googleApiClient;
  $services = $google_api_client
    ->getServices();
  if (!is_array($services)) {
    $services = [
      $services,
    ];
  }
  $classes = \Drupal::config('google_api_client.google_api_classes')
    ->get('google_api_client_google_api_classes');
  $return = [];
  foreach ($services as $service) {
    $return[$service] = new $classes[$service]($this->googleClient);
  }
  return $return;
}