class TimeZoneResolver implements EventSubscriberInterface (View source)

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

Sets the time zone using date_default_timezone_set().

Properties

protected ConfigFactoryInterface $configFactory

The config.

Methods

__construct(AccountInterface $current_user, ConfigFactoryInterface $config_factory)

TimeZoneResolver constructor.

setDefaultTimeZone()

Sets the default time zone.

onConfigSave(ConfigCrudEvent $event)

Updates the default time zone when time zone config changes.

static 
getSubscribedEvents()

{@inheritdoc}

string|null
getTimeZone()

Gets the time zone based on site and user configuration.

Details

__construct(AccountInterface $current_user, ConfigFactoryInterface $config_factory)

TimeZoneResolver constructor.

Parameters

AccountInterface $current_user

The current user.

ConfigFactoryInterface $config_factory

The config factory.

setDefaultTimeZone()

Sets the default time zone.

onConfigSave(ConfigCrudEvent $event)

Updates the default time zone when time zone config changes.

Parameters

ConfigCrudEvent $event

The config crud event.

static getSubscribedEvents()

{@inheritdoc}

protected string|null getTimeZone()

Gets the time zone based on site and user configuration.

Return Value

string|null

The time zone, or NULL if nothing is set.