wwaf-8.x-1.0-beta5/wwaf.install
wwaf.install
<?php
/**
* @file
* Install, update and uninstall functions for the Product module.
*/
use Drupal\Core\Session\AccountInterface;
/**
* Implements hook_install().
*/
function wwaf_install() {
// Allow all roles to view published products.
user_role_grant_permissions(AccountInterface::ANONYMOUS_ROLE, ['view wwaf entity']);
user_role_grant_permissions(AccountInterface::AUTHENTICATED_ROLE, ['view wwaf entity']);
}
/**
* Implements hook_requirements().
*/
function wwaf_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
$api_key = \Drupal::config('geolocation_google_maps.settings')
->get('google_map_api_key');
if (!$api_key) {
$requirements['wwaf_google_support'] = [
'title' => t('WWAF Google support'),
'description' => t('It is mandatory to configure Google API Key!', [
':link' => 'todo: link',
]),
'value' => new \Drupal\Component\Render\FormattableMarkup('ERROR: Google API key is not configured <a href="@url" target="_blank">go to configuration</a>', [
'@url' => \Drupal\Core\Url::fromRoute('geolocation_google_maps.settings')->toString(),
]),
'severity' => REQUIREMENT_ERROR,
];
}
else {
$requirements['wwaf_google_support'] = [
'title' => t('WWAF Google support'),
'description' => t('Google API Key is successfully configured'),
'value' => 'OK',
'severity' => REQUIREMENT_INFO,
];
}
}
return $requirements;
}
