You are here

function google_api_client_load_library in Google API PHP Client 8.2

Same name and namespace in other branches
  1. 8.4 google_api_client.module \google_api_client_load_library()
  2. 8.3 google_api_client.module \google_api_client_load_library()
4 calls to google_api_client_load_library()
Callback::callbackUrl in src/Controller/Callback.php
Callback URL for Google API Auth.
GoogleApiClientService::getClient in src/Service/GoogleApiClientService.php
Function to retrieve the google client for different operations.
google_api_client_requirements in ./google_api_client.install
Implements hook_requirements().
_google_api_client_read_scope_info in ./google_api_client.module
Helper function which reads the installed library and discovery api to build cache for scopes and names.

File

./google_api_client.module, line 150
Google Auth Api for drupal.

Code

function google_api_client_load_library($return_path = FALSE) {
  $library = \Drupal::service('library.discovery')
    ->getLibraryByName('google_api_client', 'google-api-php-client');
  if ($library) {
    if (class_exists('Google_Client')) {

      // Composer install so no problem with lib.
      if ($return_path) {
        return '';
      }
      return TRUE;
    }
    else {
      $php_files = array_keys($library['php']);
      $library_exists = file_exists($php_files[0]);
      if ($library_exists) {
        require_once $php_files[0];
        if ($return_path) {
          return 'libraries/google-api-php-client/';
        }
        return TRUE;
      }
    }
  }
  return FALSE;
}