Formatter: Add Event to allow other modules to modify values

Created on 24 June 2019, over 5 years ago
Updated 29 February 2024, 10 months ago

Problem/Motivation

The office hours module does not provide a way to modify the output of the opening hours table.
Instead of implementing a way to modify the render array, is it possible to modify the data that is set in the TypedData?

Proposed resolution

An alter_hook hook_office_hours_time_format_alter(string &$formatted_time) hook is added in 8.x-1.7 version, as per #3063213-14: Time format: Add hook for custom format (D7/D8) .

Alternatively, this issue adds Events in 8.x-1.13 version:
- Event PRE_FORMAT: e.g., adding a holiday for all locations in a region, changing ItemListInterface $items.
- Event POST_FORMAT: e.g., changing time format from 'am' to non-php 'A.M.', changing array $office_hours
- Event UPDATE: not implemented.

The service office_hours_subscriber.default should IMO not be used, instead create a subclass and implement the methods.

The OfficeHoursEventDispatcher now calls \Drupal::service('event_dispatcher'). Instead, third party module should subclass it.

Feature request
Status

Fixed

Version

1.12

Component

Code - formatter

Created by

🇵🇱Poland jorgik

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024