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.
core/modules/book/book.module
89: * Implements hook_node_links_alter().
91:function book_node_links_alter(array &$node_links, NodeInterface $node, array &$context) {
core/modules/comment/comment.module
195: * Implements hook_node_links_alter().
197:function comment_node_links_alter(array &$node_links, NodeInterface $node, array &$context) {
core/modules/node/node.api.php
489:function hook_node_links_alter(array &$links, NodeInterface $entity, array &$context) {
core/modules/statistics/statistics.module
49: * Implements hook_node_links_alter().
51:function statistics_node_links_alter(array
In the documentation for hook_node_links_alter(), the first parameter is called $links. In all the implementations however, it's called $node_links.
Comment | File | Size | Author |
---|---|---|---|
#4 | node-links-2587337-4.patch | 4.81 KB | sdstyles |
#2 | node-links-2587337-2.patch | 959 bytes | sdstyles |
Comments
Comment #2
sdstyles CreditAttribution: sdstyles at FFW commentedCorrected it in documentation of hook_node_links_alter()
Comment #3
GoZ CreditAttribution: GoZ at Centarro commentedIn this way, all
hook_node_links_alter()
calls and definition are consistent, but i'm not sure naming$links
$node_links
is consistent with the others naming in same context.For example:
hook_comment_links_alter()
also use$links
, so basing on this patch, we should rename it to$comment_links
to.hook_language_switch_links_alter()
also use$links
, so basing on this patch, we should rename it to$language_switch_links
to.hook_contextual_links_alter()
also use$links
, so basing on this patch, we should rename it to$contextual_links
to.hook_views_ui_display_top_links_alter()
also use$links
, so basing on this patch, we should rename it to$views_ui_display_top_links
to.We are on
hook_SOMETHING_links_alter
, so $links make reference to the something_links.If we want to keep consistence, it's should be better to replace $node_links in implementations by $links and replace existing $links in this implementations by something else more appropriate.
Comment #4
sdstyles CreditAttribution: sdstyles at FFW commentedPatch based on approach from #3
Comment #5
jhodgdonNot documentation.
Comment #6
artfrick CreditAttribution: artfrick as a volunteer commentedAfter looking into this, hook_node_links_alter only exists in these 3 modules:
The patch applies and functions as recommended. I made sure these match the API documentation for parameter names.
Comment #7
catchCommitted/pushed to 8.1.x, thanks!