Problem/Motivation
There are far, far too many ways to do exactly the same thing in Drupal. In particular, there are 4 ways to provide theme_hook_suggestions for Drupal 8:
- provide a pattern in hook_theme
- implement hook_template_suggestions()
- implement hook_template_suggestions_alter()
- pass an array to theme()
Proposed resolution
If we were to remove pattern
from hook_theme, there would only be three ways to do the same thing.
From the API:
pattern: A regular expression pattern to be used to allow this theme implementation to have a dynamic name. The convention is to use __ to differentiate the dynamic portion of the theme.
For all current uses of 'pattern' in core we should use hook_template_suggestions() instead.
Remaining tasks
Remove pattern
from hook_theme().
User interface changes
None.
API changes
Remove pattern
from hook_theme().
Related Issues
#1751194: Introduce hook_theme_suggestions[_HOOK]() and hook_theme_suggestions[_HOOK]_alter()
Comments
Comment #1
tim.plunkettWe just removed these from Views, but with the expectation that
$hook . '__'
would always be added.So we could just have a global one that does
$hook . '__'
for each hook...Postponed until we can actually do this.
Comment #2
Fabianx CreditAttribution: Fabianx commentedThe idea is that the pattern is removed as an external option, but kept as an internal option.
Already now theme:8 has the assumption that the pattern is '__', so we would keep that, but purely internally.
So as core already has the pattern hardcoded for the case, where it does not _know_ the hook to use the pattern from, it makes sense to remove the 'pattern' option entirely from hook_theme() and hardcode to '__' everywhere.
Thanks!
Comment #2.0
Fabianx CreditAttribution: Fabianx commentedclarify
Comment #3
lauriiiI guess this could be done at some point in Drupal 8 release cycle because the pattern doesn't work anymore.
Comment #6
joelpittetIs this still needed? Unpostponing