Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Plugin%21...
> Name of the alter hook.
This could do with a little more precision. To get a hook 'hook_sandwich_info_alter', you want to pass in only 'sandwich_info'.
Comment | File | Size | Author |
---|---|---|---|
#14 | clarified_definition_of_parameter-2218319-14.patch | 680 bytes | Anonymous (not verified) |
#10 | clarified_definition_of_parameter-2218319-10.patch | 680 bytes | Anonymous (not verified) |
#8 | clarified_definition_of_parameter-2218319-8.patch | 679 bytes | Anonymous (not verified) |
#6 | 2218319-alterinfo-docs-6.patch | 820 bytes | longwave |
#5 | 2218319-alterinfo-docs-5.patch | 675 bytes | longwave |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedClarified the parameter $alter_hook by adding an example definition
Comment #2
JayeshSolanki CreditAttribution: JayeshSolanki commentedComment #3
BerdirThis is exactly the same behavior as drupal_alter()/ModuleHandlerInterface::alter() always has been, so maybe we should just reference to that?
Comment #4
jhodgdonThanks for the patch!
I would agree with #3, but this documentation is very short, so I think rather than *just* referencing it, we should go ahead and provide the docs, and also provide an @see link to ModuleHandlerInterface::alter().
Also, regardin the current patch:
- "Example" should not be capitalized in "For Example".
- Please do not use "foobar". Use a more representative hook name, like hook_mymodule_mydata_alter().
- In place of "to use", you might use wording like "If your alter hook is called...".
- In place of "you want to pass only", you might use more concise wording that tells what to do, such as just "pass in".
Comment #5
longwave"mymodule_data" is the example used in ModuleHandlerInterface, so let's borrow that here.
Comment #6
longwaveOr should we rename the parameter to make it more obvious it isn't just the hook name, like ModuleHandlerInterface does?
Comment #7
jhodgdonThe docs there look good. The first comma (before "for example") should be a ; though.
Changing the parameter would be OK, but it looks like $type is the same parameter name as ModuleHandlerInterface::alter($type)?
Hmmm... Can the $type here be an array?
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Extension!ModuleH...
If so, I think we should definitely make a link to ModuleHandlerInterface::alter()... it seems unlikely for plugin managers that they would want to use an array though?
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedHi I added a patch taking care of your recommendations hook_mymodule_data_alter()
Comment #9
jhodgdonGood but needs a space after the ; -- thanks! Also, neither "for" nor "example" should be capitalized, since they are in the middle of a sentence.
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #12
jhodgdonThanks, that should do it.
Comment #13
longwaveThere is a typo in #10, "mymodula_data"
Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commented@longwave Thanks for pointing out
Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #16
jhodgdonDoh! Missed that. Looks good this time. :)
Comment #17
jhodgdonThanks again! Committed to 8.x.