google_analytics_reports-8.x-3.0-rc3/modules/google_analytics_reports_api/google_analytics_reports_api.install
modules/google_analytics_reports_api/google_analytics_reports_api.install
<?php
/**
* @file
* Installation file for Google Analytics Reports API module.
*/
use Drupal\Core\Url;
use Drupal\google_analytics_reports_api\GoogleAnalyticsReportsApiFeed;
/**
* Implements hook_requirements().
*/
function google_analytics_reports_api_requirements($phase) {
$requirements = [];
if ($phase === 'runtime') {
$isFine = GoogleAnalyticsReportsApiFeed::service() && GoogleAnalyticsReportsApiFeed::service()->isAuthenticated();
$value = ($isFine) ? 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 = ($isFine) ? REQUIREMENT_OK : REQUIREMENT_ERROR;
$requirements['google_analytics_reports_api_authorization'] = [
'title' => t('Google Analytics Reports API authorization'),
'value' => $value,
'severity' => $severity,
];
}
return $requirements;
}
