Convert theme hooks to OOP

Created on 3 September 2025, about 2 months ago

Problem/Motivation

Module hooks have successfully been converted to OOP.
It would be great to convert Theme hooks to OOP.

This requires several changes and architectural changes.

  • Add theme namespaces to the container
  • Add ThemeHookCollectorPass to collect hooks
  • Optionally add HookCollectorPass with pieces that are the same for module and theme
  • Update ThemeHandler to remove just in time namespace registration
  • Create ThemeProceduralCall to allow optional includes (alternate solution needed)
  • Create ThemeImplementationList for theme implementations
  • Add updateThemes call after theme install and uninstall

Architectural decision 1
Theme hooks are different than module hooks in the following ways
1. Order is fixed
2. Only certain alters are available

We have two approaches to handling this:
First we can use Hook and throw an error if the module parameter or order parameter are set.
Second we can create a new Attribute that only has the necessary parameters

I strongly prefer the first option since it keeps the hook system closer, if we come up with a really good name for the new attribute that might be cleaner to delineate the differences.

Architectural decision 2
Currently ThemeManager is the one that handles hook execution even though we have a ThemeHandler
Do we want to move hooks execution to ThemeHandler

Steps to reproduce

N/A

Proposed resolution

  • Add theme namespaces to the container
  • Add ThemeHookCollectorPass to collect hooks
  • Optionally add HookCollectorPass with pieces that are the same for module and theme
  • Update ThemeHandler to remove just in time namespace registration
  • Create ThemeProceduralCall to allow optional includes (alternate solution needed)
  • Create ThemeImplementationList for theme implementations
  • Reuse Hook
  • Use ThemeManager

There are several test failures that look like a gap in KernelTestBase

Remaining tasks

Figure out test failures
Figure out how to split this across issues

User interface changes

N/A

Introduced terminology

TBD

API changes

oh boy

Data model changes

TBD

Release notes snippet

TBD

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component

extension system

Created by

πŸ‡ΊπŸ‡ΈUnited States nicxvan

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

Merge Requests

Comments & Activities

  • Issue created by @nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • Merge request !13148Resolve #3544715 "Convert theme hooks" β†’ (Closed) created by nicxvan
  • Pipeline finished with Failed
    about 2 months ago
    Total: 142s
    #589423
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • Merge request !13155Resolve #3544715 "Kerneltestbase" β†’ (Closed) created by nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • Pipeline finished with Failed
    about 2 months ago
    Total: 420s
    #590045
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Failures without the kernel test base changes:

    Kernel Tests

    • Drupal\Tests\editor\Kernel\EditorValidationTest
    • Drupal\Tests\block\Kernel\ConfigActions
    • Drupal\Tests\block\Kernel\NewDefaultThemeBlocks
    • Drupal\KernelTests\Core\Asset\LibraryDiscoveryIntegrationTest
    • Drupal\KernelTests\Core\Theme\ThemeSettings
    • Drupal\Tests\block\Kernel\BlockStorageUnit
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • Pipeline finished with Failed
    about 1 month ago
    Total: 1132s
    #598479
  • Pipeline finished with Failed
    about 1 month ago
    Total: 742s
    #598484
  • Pipeline finished with Failed
    about 1 month ago
    Total: 558s
    #598525
  • Pipeline finished with Failed
    about 1 month ago
    Total: 206s
    #598550
  • Merge request !13233Resolve #3544715 "Themeproceduralcall" β†’ (Closed) created by nicxvan
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 70s
    #598583
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 246s
    #598613
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 715s
    #598619
  • Pipeline finished with Failed
    about 1 month ago
    Total: 1058s
    #598631
  • Pipeline finished with Failed
    about 1 month ago
    Total: 603s
    #599132
  • Merge request !13242Resolve #3544715 "Preprocess" β†’ (Closed) created by nicxvan
  • Pipeline finished with Failed
    about 1 month ago
    Total: 315s
    #599466
  • Pipeline finished with Failed
    about 1 month ago
    Total: 628s
    #599465
  • Merge request !1Resolve #3544715 "Preprocess" β†’ (Closed) created by nicxvan
  • Pipeline finished with Failed
    about 1 month ago
    Total: 139s
    #599473
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 299s
    #599476
  • Pipeline finished with Failed
    about 1 month ago
    Total: 117s
    #599482
  • Pipeline finished with Failed
    about 1 month ago
    Total: 743s
    #599480
  • Pipeline finished with Failed
    about 1 month ago
    Total: 177s
    #599633
  • Pipeline finished with Failed
    about 1 month ago
    Total: 147s
    #599638
  • Pipeline finished with Failed
    about 1 month ago
    Total: 124s
    #599642
  • Pipeline finished with Failed
    about 1 month ago
    Total: 642s
    #599640
  • Pipeline finished with Failed
    about 1 month ago
    Total: 563s
    #599641
  • Pipeline finished with Failed
    about 1 month ago
    Total: 157s
    #599647
  • Pipeline finished with Failed
    about 1 month ago
    Total: 465s
    #599648
  • Pipeline finished with Failed
    about 1 month ago
    #602314
  • Pipeline finished with Failed
    about 1 month ago
    #602312
  • Pipeline finished with Failed
    about 1 month ago
    Total: 265s
    #602818
  • Pipeline finished with Failed
    about 1 month ago
    Total: 898s
    #602827
  • Pipeline finished with Failed
    about 1 month ago
    #602844
  • Pipeline finished with Failed
    about 1 month ago
    Total: 554s
    #602851
  • Pipeline finished with Failed
    about 1 month ago
    Total: 218s
    #603270
  • Pipeline finished with Success
    about 1 month ago
    Total: 644s
    #603269
  • Pipeline finished with Failed
    about 1 month ago
    Total: 216s
    #603716
  • Pipeline finished with Failed
    about 1 month ago
    Total: 705s
    #603714
  • Pipeline finished with Success
    about 1 month ago
    Total: 743s
    #603715
  • Pipeline finished with Failed
    about 1 month ago
    Total: 678s
    #603731
  • Pipeline finished with Success
    about 1 month ago
    Total: 945s
    #603730
  • Pipeline finished with Success
    about 1 month ago
    Total: 610s
    #604313
  • Pipeline finished with Failed
    about 1 month ago
    Total: 249s
    #604323
  • Pipeline finished with Failed
    about 1 month ago
    Total: 1039s
    #604326
  • Pipeline finished with Failed
    about 1 month ago
    Total: 170s
    #605969
  • Pipeline finished with Success
    about 1 month ago
    Total: 804s
    #605972
  • Pipeline finished with Failed
    about 1 month ago
    Total: 777s
    #605974
  • Pipeline finished with Failed
    about 1 month ago
    #606982
  • Pipeline finished with Failed
    about 1 month ago
    #606981
  • Pipeline finished with Success
    28 days ago
    Total: 843s
    #614324
  • Merge request !13412Resolve #3544715 "Convert theme hooks keyvalue" β†’ (Closed) created by nicxvan
  • Pipeline finished with Failed
    23 days ago
    Total: 179s
    #618428
  • Pipeline finished with Failed
    23 days ago
    Total: 960s
    #618634
  • Pipeline finished with Failed
    23 days ago
    Total: 681s
    #619045
  • Pipeline finished with Failed
    23 days ago
    Total: 791s
    #619060
  • Pipeline finished with Failed
    22 days ago
    Total: 627s
    #619133
  • Pipeline finished with Failed
    21 days ago
    Total: 749s
    #620072
  • Pipeline finished with Failed
    21 days ago
    Total: 808s
    #620094
  • Pipeline finished with Success
    21 days ago
    Total: 638s
    #620100
  • Pipeline finished with Failed
    20 days ago
    Total: 632s
    #622185
  • Merge request !13465Resolve #3544715 "Keyvalue theme previous" β†’ (Closed) created by nicxvan
  • Pipeline finished with Success
    17 days ago
    Total: 687s
    #625082
  • Pipeline finished with Failed
    17 days ago
    Total: 739s
    #625230
  • Pipeline finished with Failed
    17 days ago
    Total: 642s
    #625328
  • Pipeline finished with Failed
    17 days ago
    Total: 662s
    #625423
  • Pipeline finished with Failed
    17 days ago
    Total: 622s
    #625428
  • Pipeline finished with Failed
    17 days ago
    Total: 1384s
    #625447
  • Pipeline finished with Failed
    17 days ago
    Total: 603s
    #625466
  • Pipeline finished with Success
    17 days ago
    Total: 755s
    #625472
  • Merge request !13467Resolve #3544715 "Keyvalue theme with invoke" β†’ (Closed) created by nicxvan
  • Pipeline finished with Canceled
    16 days ago
    Total: 273s
    #625515
  • Pipeline finished with Failed
    16 days ago
    Total: 727s
    #625523
  • Pipeline finished with Failed
    16 days ago
    #625529
  • Pipeline finished with Failed
    16 days ago
    Total: 367s
    #625964
  • Pipeline finished with Success
    16 days ago
    Total: 1104s
    #625979
  • Pipeline finished with Success
    16 days ago
    Total: 802s
    #626013
  • Pipeline finished with Failed
    16 days ago
    Total: 831s
    #626175
  • Pipeline finished with Success
    16 days ago
    #626188
  • Pipeline finished with Failed
    15 days ago
    Total: 560s
    #626761
  • Pipeline finished with Success
    15 days ago
    Total: 1524s
    #626783
  • Pipeline finished with Failed
    15 days ago
    Total: 153s
    #626997
  • Pipeline finished with Success
    14 days ago
    Total: 1131s
    #627271
  • Pipeline finished with Success
    14 days ago
    Total: 711s
    #627744
  • Pipeline finished with Canceled
    14 days ago
    Total: 251s
    #628191
  • Pipeline finished with Canceled
    14 days ago
    Total: 320s
    #628194
  • Pipeline finished with Success
    14 days ago
    Total: 875s
    #628196
  • Pipeline finished with Success
    13 days ago
    Total: 1044s
    #628933
  • Pipeline finished with Failed
    11 days ago
    Total: 161s
    #631684
  • Pipeline finished with Success
    11 days ago
    #631850
  • Pipeline finished with Success
    8 days ago
    Total: 804s
    #633952
  • Pipeline finished with Failed
    8 days ago
    Total: 861s
    #634240
  • Merge request !13545Support preprocess β†’ (Closed) created by berdir
  • Pipeline finished with Failed
    8 days ago
    Total: 503s
    #634347
  • Merge request !2Revert "Remove includes for themes" β†’ (Open) created by nicxvan
  • Pipeline finished with Failed
    8 days ago
    Total: 796s
    #634412
  • Pipeline finished with Success
    8 days ago
    Total: 5173s
    #634413
  • Pipeline finished with Success
    7 days ago
    Total: 3739s
    #634471
  • Pipeline finished with Failed
    7 days ago
    Total: 917s
    #634501
  • Pipeline finished with Success
    7 days ago
    Total: 1689s
    #634517
  • Pipeline finished with Success
    6 days ago
    #636252
  • Pipeline finished with Failed
    5 days ago
    Total: 7044s
    #637247
  • Pipeline finished with Failed
    5 days ago
    Total: 1310s
    #637458
  • Pipeline finished with Success
    4 days ago
    Total: 2143s
    #638255
  • Pipeline finished with Failed
    4 days ago
    Total: 955s
    #638390
  • Pipeline finished with Success
    4 days ago
    Total: 848s
    #638569
  • Pipeline finished with Failed
    4 days ago
    Total: 578s
    #638658
  • Pipeline finished with Failed
    4 days ago
    Total: 819s
    #638674
  • Pipeline finished with Success
    4 days ago
    Total: 653s
    #638698
  • Pipeline finished with Success
    4 days ago
    Total: 579s
    #638919
Production build 0.71.5 2024