[PP-1] Refactor theme hooks/registry into plugin managers

Created on 14 April 2017, over 7 years ago
Updated 26 January 2024, 11 months ago

Currently blocked on #2954562: [PP-2] Create provider based plugin managers

Problem/Motivation

Most of the effort in 8.x to "update the theme system" was focused primarily around converting everything to Twig.

While this is all well and good, Twig is ultimately the last step in the "theming" process.

We really didn't touch a lot of the theme system internals, just moved them around a bit into other OO classes/services.

We're still using antiquated hooks to define the theme registry and templates it may provide.

It's time we modernize it using existing systems.

See #2863819-22: Convert theme hooks (defined by hook_theme()) to be objects for more discussion regarding this topic.

Proposed resolution

Create two new annotated plugins/manangers:

  • @Theme - Used to define a theme and handle the preprocessing/rendering.
  • @Template - Actual template definitions (formerly known as "theme hooks" provided by hook_theme())

An example in contrib (still a WIP):
https://cgit.drupalcode.org/plus/tree/src/ThemePluginManager.php?h=8.x-4.x

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

📌 Task
Status

Postponed

Version

11.0 🔥

Component
Theme 

Last updated about 14 hours ago

Created by

🇺🇸United States markhalliwell

Live updates comments and jobs are added and updated live.
  • needs profiling

    It may affect performance, and thus requires in-depth technical reviews and profiling.

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.

  • 🇬🇧United Kingdom joachim

    > But there is no fixed 1:1 mapping between theme hook names and template files.

    This is something that's really confusing about the theming system. There is often a theme hook name and a template file with a matching name, which can make it seem like there's something automatic going on, but AFAICT there isn't.

    This also makes it confusing to understand what you're going to get if you use #theme vs #type in render arrays.

    E.g. #theme => table and #type => table give you slightly different results!

  • 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin

    This is something that's really confusing about the theming system. There is often a theme hook name and a template file with a matching name, which can make it seem like there's something automatic going on, but AFAICT there isn't.

    Exactly this ^^ !

Production build 0.71.5 2024