On #2299715: [meta] Move core hooks from system.api.php to core.api.php or other files an inventory was done of hooks in core/modules/system/system.api.php that are not related to the System module per se.
The following hooks are related to the theme and rendering system, and should be moved to theme.api.php:
hook_js_alter(), hook_library_info_alter(), hook_library_alter(), hook_css_alter()
hook_element_info(), hook_element_info_alter()
hook_page_build(), hook_page_alter()
hook_theme(), hook_theme_registry_alter(), hook_template_preprocess_default_variables_alter()
Also, the following two hooks are duplicated in system.api.php and theme.api.php. They should be removed from system.api.php:
hook_themes_installed(), hook_themes_uninstalled()
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | 2307859-30.patch | 38.43 KB | rpayanm |
| #30 | 2307859-interdiff.txt | 736 bytes | rpayanm |
| #24 | 2307859-24.patch | 38.17 KB | rpayanm |
| #19 | move_hooks_to_theme_api-2307859-18.patch | 41.05 KB | shumer |
| #15 | move_hooks_to_theme_api-2307859-14.patch | 40.79 KB | shumer |
Comments
Comment #1
jhodgdonHere's a patch. Note that theme.api.php did not have a @file doc block, nor were its hooks being added to the Hooks group/topic on api.drupal.org. So this has also been remedied.
So, for the hooks... I just used copy/paste, so the hook function bodies and documentation should be identical between the files.
To review:
- Did I remove the right hooks from system.api.php
- Did they all make it into theme.api.php
- Are the choices good (should these hooks be moved).
Comment #2
star-szrI reviewed the patch and it seems quite reasonable to me. All 11 hooks were moved over. I think any issues with these hooks would probably end up in the 'theme system' component so theme.api.php seems like a good fit! Thanks @jhodgdon :)
Comment #3
star-szrAlthough it does need a reroll… :)
Comment #4
dankh commentedI'm re-rolling it.
Comment #5
dankh commentedPatch re-rolled. There were couple of conflicts in the comments, I kept those from head. In theme.api.php I have also checked and updated the links in the overview docblock :
https://www.drupal.org/documentation/theme - generic entry page, link left as is
https://www.drupal.org/node/722174 - Theme API, entry page which needs to be updated, link left as is
https://drupal.org/node/933976 - Using the theme layer (Drupal 7.x), D7 only link removed
https://drupal.org/node/930760 - Render Arrays in Drupal 7, D7 only link removed
Added the link : https://www.drupal.org/theme-guide/8
Comment #6
jhodgdondankh: Um. ... please, this issue is *just about moving the hooks*. We do not want those links removed, actually -- until we have new Drupal 8 documentation for those areas, we should continue to link to the Drupal 7 documentation, which is better than nothing. Also, fixing the links would be a separate issue.
So can you please make another patch that just moves the hooks, as they are now in head, from one file to the other? Or I can do it... but that is all we want in the patch.
Thanks!
Comment #7
jhodgdonComment #8
dankh commentedI'm re-rolling it.
Comment #9
dankh commentedPatch re-rolled, no changes to links were made. Sorry about that I'm fairly new contributor.
Comment #10
jhodgdonNot a problem! Sorry if I came across as angry or annoyed in any way in my earlier review. Thanks for the new patch!
Hm, the patch came out a bit weird (silly diff util!). So... a bit hard to review. Can you confirm that you started from an updated D8 repository and just did cut-and-paste to make it?
Comment #11
dankh commentedYou're right the patch doesn't look good. I followed this guide https://www.drupal.org/patch/reroll .
But when I look again I see that :
doesn't exist in the current codebase.
I'll do it again. Sorry about that.
Comment #12
jhodgdonI don't think a reroll is really what we need here. We probably just need a new patch that starts over with a clean "git pull" on Drupal 8, then opens system.api.php, and cut/pastes the desired hooks into theme.api.php.
Comment #13
star-szrAgreed, a reroll is just going to make things harder in this case. Thanks for working on this @dankh!
Comment #14
jhodgdonFor now...
Comment #15
shumer commentedHere is new patch for test
Comment #16
jhodgdonLooks good to me, thanks!
Comment #17
jhodgdonSee also #2349221: No @addtogroup hooks in theme.api.php
Comment #18
shumer commentedComment #19
shumer commentedPatch updated with @addtogroup hook
Comment #20
jhodgdonOK, still RTBC then. Thanks!
Comment #21
alexpottNeeds a reroll and what about hook_themes_installed and hook_themes_uninstalled - I think they are currently in both places :) - They should only be in theme.api.php (i think).
Comment #22
opdaviesRemoving duplicate tags.
Comment #23
jhodgdonHah, didn't notice that about hook_themes_installed() and hook_themes_uninstalled(). That would indeed be a good addition to this patch. I took a look at the documentation/body in system.api.php and theme.api.php, and I think the versions in theme.api.php are slightly better. So let's remove hook_themes_installed() and hook_themes_uninstalled() from system.api.php.
Comment #24
rpayanmrerolled and removed from system.api.php:
hook_themes_installed(), hook_themes_uninstalled()
I have a question hook_themes_installed() in system.api.php should not be equal to those of theme.api.php
Here the comparison:
system.api.php:
theme.api.php:
Comment #25
jhodgdonUm... Not sure what you are asking in #24. In #23, I said " I took a look at the documentation/body in system.api.php and theme.api.php, and I think the versions in theme.api.php are slightly better. So let's remove hook_themes_installed() and hook_themes_uninstalled() from system.api.php." Does that answer your question?
Also... When you say you "rerolled" the patch, did you reroll or do a clean cut-and-paste? Because rerolling in the traditional way is **not** the right thing to do in this patch. You need to start from a clean git pull, and cut/paste the current hooks from one way to another, in order to preserve the current status of those hook docs.
Comment #26
rpayanmYes, that I repond to my question :)
And I start from a clean git pull and then cut-and-paste the current hooks from one way to another, the only thing I have left is @addtogroup hook, I do not where to put it :(
Greetings.
Comment #27
jhodgdonIf you look at some of the other *.api.php files with hooks in them, you may be able to see what to do in this file. The idea is that the @addtogroup hooks {} section starts before the first hook in the file, and ends after the last hook, so that all the hooks are added to the "hooks" topic.
Comment #28
rpayanmThen everything should be surrounded by @addtogroup hooks {}? because all function are:
function hook_*Comment #29
jhodgdonRight, but just the hooks, not the @defgroup pieces. Thanks!
Comment #30
rpayanmNow with @addtogroup hook :)
Comment #31
jhodgdonThanks! I committed this to 8.0.x. On commit, fixed the missing newline in theme.api.php and moved a couple more hooks over.