Skip to content

Commit

Permalink
EWPP-2033: Provide upgrade path to adapt the date formats.
Browse files Browse the repository at this point in the history
  • Loading branch information
22Alexandra authored and upchuk committed Mar 16, 2022
1 parent c39d67d commit 601233d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
langcode: en
status: true
dependencies: { }
id: oe_event_programme_date_with_hour_with_timezone
id: oe_event_programme_date_hour_timezone
label: 'Event programme date with hour with timezone'
locked: false
pattern: 'j M Y, h:i A T'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
langcode: en
status: true
dependencies: { }
id: oe_event_programme_hour_timezone
label: 'Event programme hour with timezone'
locked: false
pattern: 'h:i A T'
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,19 @@ function oe_theme_content_event_post_update_30001() {
$date_format->save();
}
}

/**
* Update Event programme date formats.
*/
function oe_theme_content_event_post_update_30002(): void {
// Remove "Event programme date with timezone" as it's not used anymore.
$date_timezone = DateFormat::load('oe_event_programme_date_timezone');
$date_timezone->delete();

// Create new time format with timezone.
$storage = new FileStorage(drupal_get_path('module', 'oe_theme_content_event') . '/config/post_updates/30002_event_programme_date_format');
$config = $storage->read('core.date_format.oe_event_programme_hour_timezone');
$config['_core']['default_config_hash'] = Crypt::hashBase64(serialize($config));
$date_format = DateFormat::create($config);
$date_format->save();
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ProgrammeExtraField extends EventExtraFieldBase {
/**
* Programme datetime with timezone format.
*/
const PROGRAMME_DATETIME_TIMEZONE_FORMAT = 'oe_event_programme_date_with_hour_with_timezone';
const PROGRAMME_DATETIME_TIMEZONE_FORMAT = 'oe_event_programme_date_hour_timezone';

/**
* Programme date format.
Expand Down

0 comments on commit 601233d

Please sign in to comment.