function TimeZoneResolver::onConfigSave

Same name in other branches
  1. 9 core/modules/system/src/TimeZoneResolver.php \Drupal\system\TimeZoneResolver::onConfigSave()
  2. 8.9.x core/modules/system/src/TimeZoneResolver.php \Drupal\system\TimeZoneResolver::onConfigSave()
  3. 10 core/modules/system/src/TimeZoneResolver.php \Drupal\system\TimeZoneResolver::onConfigSave()

Updates the default time zone when time zone config changes.

Parameters

\Drupal\Core\Config\ConfigCrudEvent $event: The config crud event.

File

core/modules/system/src/TimeZoneResolver.php, line 64

Class

TimeZoneResolver
Event handler that resolves time zone based on site and user configuration.

Namespace

Drupal\system

Code

public function onConfigSave(ConfigCrudEvent $event) {
    $saved_config = $event->getConfig();
    if ($saved_config->getName() === 'system.date' && ($event->isChanged('timezone.default') || $event->isChanged('timezone.user.configurable'))) {
        $this->setDefaultTimeZone();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.