Provide a mechanism to mark entire twig templates as deprecated

Created on 7 July 2020, over 4 years ago
Updated 2 November 2023, about 1 year ago

Problem/Motivation

Sometimes we need to deprecate entire twig templates. For example, ๐Ÿ› Datetime and Datelist elements should render as fieldsets Needs work would mean core stops using the datetime-wrapper template entirely and use a fieldset instead. We probably don't want to completely remove the datetime-wrapper template in the first pass... it'd be nice if we had a way to leave it around but mark it deprecated to warn site builders that core won't keep providing that template in the future.

Proposed resolution

  • Add a 'deprecated' key to the arrays returned by hook_theme(), with the deprecation message to use as a value.
  • Update \Drupal\Core\Theme\ThemeManager::render() so that if it's being asked to render using a template that's been marked deprecated that it will trigger_error() with the supplied message.

Remaining tasks

  1. Discuss the proposed resolution and make sure that's what we want to do.
  2. Do it.
  3. Add some tests to make sure it works.
  4. Reviews / sign-off.
  5. Draft change record about it.
  6. RTBC.
  7. Commit.
  8. Unblock ๐Ÿ› Datetime and Datelist elements should render as fieldsets Needs work and other issues that need to do this.

User interface changes

TBD. Basically none.

API changes

TBD. Probably a new allowed key in the values returned by hook_theme().

Data model changes

Probably none.

Release notes snippet

TBD

๐Ÿ“Œ Task
Status

Fixed

Version

10.2 โœจ

Component
Themeย  โ†’

Last updated about 1 hour ago

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States dww

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