Dependency on datetime Module Missing in CalendarHelper for DateTimeItemInterface::DATE_STORAGE_FORMAT

Created on 26 November 2024, 26 days ago

Problem/Motivation

The CalendarHelper class references the constant DATE_STORAGE_FORMAT from DateTimeItemInterface, which is provided by the datetime module. This creates an implicit dependency on the datetime module. If the datetime module is not enabled, it results in an error:

Class "Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface" not found

This issue occurs because the datetime module is not a declared dependency of the module or code using CalendarHelper.

Steps to reproduce

Don't enable the datetime module and try to use the views templates.

Proposed resolution

  1. Add the datetime module as a dependency in the info.yml file of the module using CalendarHelper.
    dependencies:
      - datetime:datetime
    
  2. Update the documentation for CalendarHelper to indicate that it requires the datetime module.
  3. Consider using dependency injection or an alternative approach to reduce hard dependencies where feasible.
  4. Test the solution to ensure that the CalendarHelper works correctly with the datetime module enabled.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada joelpittet Vancouver

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024