This is blocked by #2869859: [PP-1] Refactor theme hooks/registry into plugin managers.
Problem/Motivation
All changes to $variables
that will be printed in templates currently happen in the same place, preprocess. Things that happen in preprocess include both creating initial variables and then altering those variables later.
Proposed resolution
Use a standard hook naming convention, exactly like the FAPI does. These standardized hooks would allow the theme system's phases to be split into a more systemic and easier to understand process. This issue is a meta for moving all the things we are currently doing in preprocess into their appropriate places.
Remaining tasks
- @todo
User interface changes
None.
API changes
Deprecate hook_preprocess()
.
Related Issues
#2035055: Introduce hook_theme_prepare[_alter]() and remove hook_preprocess_HOOK()
Comments
Comment #1
markhalliwellI'll spearhead this once prepare is in.
Comment #2
markhalliwellCleaner title, moving the "deprecation" of hook_preprocess() to #2035055: Introduce hook_theme_prepare[_alter]() and remove hook_preprocess_HOOK()
Comment #3
star-szrMoving to 9.x, same as #2035055: Introduce hook_theme_prepare[_alter]() and remove hook_preprocess_HOOK().
Comment #4
catchMoved #2035055: Introduce hook_theme_prepare[_alter]() and remove hook_preprocess_HOOK() back to 8.x since I think it's worth exploring bc layers for it.
If we did that, then conversions could also happen against 8.x.
Comment #5
joelpittetOther than a a name change, what would be gained from changing the hook name? I agree the name is better but people from D7 know
hook_preprocess()
I think it would be maybe worth looking into something other than hooks for this. Maybe some kind of alter plugin or event so we can "stop propagation", change priority/weights, or fancy things like that.
Comment #10
joelpittetI don't think the name change is worth the BC layer. I may be missing something, but what do we gain?
Comment #11
andypostProbably this could be closed
Comment #12
markhalliwellActually, this still needs to happen... although the direction has changed a bit (more OO).
I suppose we can just repurpose this for actually migrating all of core once #2869859: [PP-1] Refactor theme hooks/registry into plugin managers is actually implemented.
These will both be big tasks and should likely be separate issues anyway.
I still like the name change from "preprocess" to "prepare" though, so we can use that as the new template plugin method name.