Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
node system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
25 Jun 2025 at 02:03 UTC
Updated:
1 Aug 2025 at 07:09 UTC
Jump to comment: Most recent
NodeHooks1::formSystemThemesAdminFormAlter should go into NodeFormHooks along with the submission callback.
Move NodeHooks1::formSystemThemesAdminFormAlter and node_form_system_themes_admin_form_submit into NodeFormHooks
Review
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
acbramley commentedComment #4
acbramley commentedComment #5
smustgrave commentedThis seems to make sense as other alters are in NodeHooks but imagine once the structure standard is decided this will have to be updated again.
Comment #6
catchI'm not sure about this going into theme hooks.
Currently that class only has a preprocess hook in it - which means it'll be instantiated on render cache misses for nodes (quite often). Not sure if those requests already load ConfigFactory but they might not.
The theme form alter is on the other hand only called when you're on the actual theme settings page, which is very, very infrequent. Also while it has the word theme in it, is it really a theme hook as such?
Comment #7
smustgrave commentedShould this be postponed for when the node hooks are restructured?
Comment #8
berdirI had the same thought, I'd probably put this in NodeFormHooks, even though there's only one of those in node module.
(FWIW, ConfigFactory is used a lot in bootstrap and rendering, _very_ unlikely that's not instantiated at this point.)
Comment #9
acbramley commentedNo, there's way too much bikeshedding in that, let's just agree on where these hooks should go.
I put them in ThemeHooks because it's dealing with theme stuff, but form hooks is fine by me.
Comment #10
smustgrave commentedThink should leave follow the structure did for taxonomy
Comment #11
nicxvan commentedThe structure I proposed is they go in the file that has the hook is defined in. hook form alter is defined in form.api.php so NodeFormHooks.
Then we can make performance considerations and split out a specific hook if it's particularly expensive. We don't have a naming convention for that yet.
Comment #12
nicxvan commentedAlso we don't want to use $this in form callbacks as @berdir explains here: #3514161: Better document how form submit callbacks should be called
Comment #13
acbramley commentedThere's not a clear "right way" defined there? What should it be?
Comment #14
acbramley commentedWe could do
$form['#submit'][] = [self::class, 'systemThemesAdminFormSubmit'];and then make it static and remove the DI?Comment #15
nicxvan commentedBerdir understands this better than I do at the moment.
But as far as I understand you're right.
If the submit callback goes through class resolver then di would still work but I don't think it does yet.
There is another issue to handle that I think.
Comment #16
acbramley commentedComment #17
acbramley commentedWhat should we do here then? Leave as is, or convert to a static callback without DI?
Comment #18
nicxvan commentedI think static callback like we did in file: https://www.drupal.org/project/drupal/issues/3534092
Comment #19
acbramley commentedDone, should be good to RTBC now
Comment #20
nicxvan commentedI agree, looks great now.
Comment #21
catchComment #22
catchNeeds a rebase after another node hooks issue landed.
It would be good to open a follow-up to discuss whether there's a DI-friendly option for form callbacks. Could we use service notation maybe?
Comment #23
nicxvan commentedI think we can have that discussion in: #3514161: Better document how form submit callbacks should be called right?
Comment #24
berdirThanks for the reminder, I had wanted to this, I think we just need to connect the dots: #3536726: Use CallableResolver for form callbacks
Comment #25
acbramley commentedJust did a straight merge since the first commit in this MR conflicted horribly.
Comment #27
catchCommitted/pushed to 11.x, thanks!