You are here

function google_analytics_reports_api_requirements in Google Analytics Reports 8.3

Same name and namespace in other branches
  1. 7.3 google_analytics_reports_api/google_analytics_reports_api.install \google_analytics_reports_api_requirements()

Implements hook_requirements().

File

google_analytics_reports_api/google_analytics_reports_api.install, line 13
Installation file for Google Analytics Reports API module.

Code

function google_analytics_reports_api_requirements($phase) {
  $requirements = [];
  if ($phase == 'runtime') {
    $access_token = \Drupal::state()
      ->get('google_analytics_reports_api.access_token');
    $value = $access_token ? t('You have successfully authorized.') : t('You must <a href="@url">authorize</a> Drupal to use your Google Analytics account before you can view reports.', [
      '@url' => Url::fromRoute('google_analytics_reports_api.settings')
        ->toString(),
    ]);
    $severity = $access_token ? REQUIREMENT_OK : REQUIREMENT_ERROR;
    $requirements['google_analytics_reports_api_authorization'] = [
      'title' => t('Google Analytics Reports API authorization'),
      'value' => $value,
      'severity' => $severity,
    ];
  }
  return $requirements;
}