Convert theme hooks to OOP

Created on 3 September 2025, about 1 month 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" β†’ (Open) created by nicxvan
  • Pipeline finished with Failed
    about 1 month ago
    Total: 142s
    #589423
  • Pipeline finished with Running
    about 1 month ago
    #589430
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • Pipeline finished with Failed
    about 1 month ago
    Total: 176s
    #589545
  • Pipeline finished with Failed
    about 1 month ago
    Total: 606s
    #589557
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • Merge request !13155Resolve #3544715 "Kerneltestbase" β†’ (Closed) created by nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • Pipeline finished with Failed
    about 1 month 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
    25 days ago
    #596481
  • Pipeline finished with Failed
    22 days ago
    Total: 1132s
    #598479
  • Pipeline finished with Failed
    22 days ago
    Total: 742s
    #598484
  • Pipeline finished with Failed
    22 days ago
    Total: 558s
    #598525
  • Pipeline finished with Failed
    22 days ago
    Total: 206s
    #598550
  • Pipeline finished with Failed
    22 days ago
    Total: 711s
    #598553
  • Pipeline finished with Failed
    22 days ago
    Total: 719s
    #598562
  • Merge request !13233Resolve #3544715 "Themeproceduralcall" β†’ (Closed) created by nicxvan
  • Pipeline finished with Canceled
    22 days ago
    Total: 70s
    #598583
  • Pipeline finished with Failed
    22 days ago
    Total: 1113s
    #598584
  • Pipeline finished with Canceled
    22 days ago
    Total: 207s
    #598612
  • Pipeline finished with Canceled
    22 days ago
    Total: 246s
    #598613
  • Pipeline finished with Canceled
    22 days ago
    Total: 715s
    #598619
  • Pipeline finished with Canceled
    22 days ago
    Total: 324s
    #598621
  • Pipeline finished with Failed
    22 days ago
    Total: 649s
    #598626
  • Pipeline finished with Failed
    22 days ago
    Total: 157s
    #598630
  • Pipeline finished with Failed
    22 days ago
    Total: 1058s
    #598631
  • Pipeline finished with Failed
    22 days ago
    Total: 603s
    #599132
  • Merge request !13242Resolve #3544715 "Preprocess" β†’ (Open) created by nicxvan
  • Pipeline finished with Failed
    22 days ago
    Total: 147s
    #599215
  • Pipeline finished with Failed
    22 days ago
    Total: 173s
    #599222
  • Pipeline finished with Failed
    22 days ago
    Total: 129s
    #599331
  • Pipeline finished with Failed
    21 days ago
    Total: 315s
    #599466
  • Pipeline finished with Failed
    21 days ago
    Total: 628s
    #599465
  • Merge request !1Resolve #3544715 "Preprocess" β†’ (Open) created by nicxvan
  • Pipeline finished with Failed
    21 days ago
    Total: 139s
    #599473
  • Pipeline finished with Failed
    21 days ago
    Total: 156s
    #599475
  • Pipeline finished with Canceled
    21 days ago
    Total: 299s
    #599476
  • Pipeline finished with Failed
    21 days ago
    Total: 117s
    #599482
  • Pipeline finished with Failed
    21 days ago
    Total: 653s
    #599481
  • Pipeline finished with Failed
    21 days ago
    Total: 743s
    #599480
  • Pipeline finished with Failed
    21 days ago
    Total: 177s
    #599633
  • Pipeline finished with Failed
    21 days ago
    Total: 148s
    #599637
  • Pipeline finished with Failed
    21 days ago
    Total: 147s
    #599638
  • Pipeline finished with Failed
    21 days ago
    Total: 124s
    #599642
  • Pipeline finished with Failed
    21 days ago
    Total: 642s
    #599640
  • Pipeline finished with Failed
    21 days ago
    Total: 563s
    #599641
  • Pipeline finished with Failed
    21 days ago
    Total: 157s
    #599647
  • Pipeline finished with Failed
    21 days ago
    Total: 465s
    #599648
  • Pipeline finished with Failed
    19 days ago
    #602315
  • Pipeline finished with Failed
    19 days ago
    #602314
  • Pipeline finished with Failed
    19 days ago
    #602312
  • Pipeline finished with Failed
    18 days ago
    Total: 265s
    #602818
  • Pipeline finished with Failed
    18 days ago
    Total: 586s
    #602825
  • Pipeline finished with Failed
    18 days ago
    Total: 898s
    #602827
  • Pipeline finished with Failed
    18 days ago
    #602844
  • Pipeline finished with Failed
    18 days ago
    Total: 493s
    #602849
  • Pipeline finished with Failed
    18 days ago
    Total: 554s
    #602851
  • Pipeline finished with Failed
    18 days ago
    Total: 218s
    #603270
  • Pipeline finished with Success
    18 days ago
    Total: 644s
    #603269
  • Pipeline finished with Success
    18 days ago
    Total: 984s
    #603267
  • Pipeline finished with Failed
    17 days ago
    Total: 216s
    #603716
  • Pipeline finished with Failed
    17 days ago
    Total: 705s
    #603714
  • Pipeline finished with Success
    17 days ago
    Total: 743s
    #603715
  • Pipeline finished with Failed
    17 days ago
    Total: 262s
    #603732
  • Pipeline finished with Failed
    17 days ago
    Total: 678s
    #603731
  • Pipeline finished with Success
    17 days ago
    Total: 945s
    #603730
  • Pipeline finished with Canceled
    16 days ago
    Total: 370s
    #604302
  • Pipeline finished with Success
    16 days ago
    Total: 610s
    #604313
  • Pipeline finished with Failed
    16 days ago
    Total: 249s
    #604323
  • Pipeline finished with Failed
    16 days ago
    Total: 1039s
    #604326
  • Pipeline finished with Success
    16 days ago
    Total: 748s
    #604349
  • Pipeline finished with Canceled
    15 days ago
    Total: 79s
    #605626
  • Pipeline finished with Failed
    15 days ago
    Total: 163s
    #605627
  • Pipeline finished with Failed
    15 days ago
    Total: 593s
    #605650
  • Pipeline finished with Failed
    14 days ago
    Total: 170s
    #605969
  • Pipeline finished with Failed
    14 days ago
    Total: 182s
    #605975
  • Pipeline finished with Success
    14 days ago
    Total: 804s
    #605972
  • Pipeline finished with Failed
    14 days ago
    Total: 777s
    #605974
  • Pipeline finished with Failed
    13 days ago
    #606982
  • Pipeline finished with Failed
    13 days ago
    #606981
  • Pipeline finished with Failed
    6 days ago
    Total: 191s
    #614316
  • Pipeline finished with Success
    6 days ago
    Total: 843s
    #614324
  • Pipeline finished with Failed
    2 days ago
    Total: 179s
    #618428
  • Pipeline finished with Failed
    2 days ago
    Total: 896s
    #618434
  • Pipeline finished with Failed
    2 days ago
    Total: 960s
    #618634
  • Pipeline finished with Failed
    1 day ago
    Total: 681s
    #619045
  • Pipeline finished with Failed
    1 day ago
    Total: 791s
    #619060
  • Pipeline finished with Failed
    1 day ago
    Total: 1050s
    #619100
  • Pipeline finished with Failed
    1 day ago
    Total: 627s
    #619133
  • Pipeline finished with Failed
    1 day ago
    Total: 501s
    #619142
  • Pipeline finished with Failed
    about 5 hours ago
    Total: 749s
    #620072
  • Pipeline finished with Failed
    about 4 hours ago
    Total: 808s
    #620094
  • Pipeline finished with Success
    about 4 hours ago
    Total: 638s
    #620100
Production build 0.71.5 2024