timezone_detect.install in Timezone Detect 8
Same filename and directory in other branches
(Un)installs the Timezone Detect module.
File
timezone_detect.installView source
<?php
/**
* @file
* (Un)installs the Timezone Detect module.
*/
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\timezone_detect\TimezoneDetectInterface;
use Drupal\user\UserInterface;
/**
* Implements hook_requirements().
*/
function timezone_detect_requirements($phase) {
$requirements = array();
switch ($phase) {
case 'runtime':
$system_date_config = \Drupal::config('system.date');
$timezone_detect_config = \Drupal::config('timezone_detect.settings');
// Check that default user timezone is set to "empty timezone", or that
// Timezone Detect is configured to update user timezone on every login
// (otherwise automatic timezone detection will not work).
$default_timezone_okay = FALSE;
if ($timezone_detect_config
->get('mode') != TimezoneDetectInterface::MODE_DEFAULT || $system_date_config
->get('timezone.user.configurable') && $system_date_config
->get('timezone.user.default') == UserInterface::TIMEZONE_EMPTY) {
$default_timezone_okay = TRUE;
}
if (!$default_timezone_okay) {
$requirements['timezone_detect'] = array(
'title' => t('Timezone detect'),
'value' => t('Incompatible default user timezone'),
'description' => t('For automatic timezone detection to work correctly, please change default user timezone to "empty timezone" on your site\'s <a href=":regional_settings_url">regional settings page</a>.', [
':regional_settings_url' => Url::fromRoute('timezone_detect.admin')
->toString(),
]),
'severity' => REQUIREMENT_ERROR,
);
}
break;
}
return $requirements;
}
Functions
Name | Description |
---|---|
timezone_detect_requirements | Implements hook_requirements(). |