You are here

function gauth_requirements in Google Auth 8

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

Implements hook_requirements().

File

./gauth.install, line 10
Install and uninstall functions for the Google OAuth module.

Code

function gauth_requirements($phase) {
  if ($phase != 'runtime') {
    return [];
  }
  $library_exists = gauth_load_library();
  $url = \Drupal\Core\Link::fromTextAndUrl(t('here'), \Drupal\Core\Url::fromUri('https://github.com/google/google-api-php-client/releases'))
    ->toString();
  $documentation = \Drupal\Core\Link::fromTextAndUrl(t('google api php client installation'), \Drupal\Core\Url::fromUri('https://github.com/google/google-api-php-client#installation'))
    ->toString();
  $version = isset($library_exists['versions']) && !empty($library_exists['versions']) ? array_keys($library_exists['versions']) : array(
    '2.4.0',
  );
  return [
    'google-api-php-client' => [
      'title' => t('Google Api PHP Client'),
      'value' => $library_exists ? t('Installed') . ' ' . Google_Client::LIBVER : t('Not installed'),
      'description' => $library_exists ? '' : t('Install version "@version" or latest version of the Google api php client library code (from %here) in a libraries directory such as "libraries/google-api-php-client". You can also use composer to install, read more at %documentation.  The path should be "libraries/google-api-php-client"', [
        '@version' => $version[0],
        '%here' => $url,
        '%documentation' => $documentation,
      ]),
      'severity' => $library_exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    ],
  ];
}