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.
Many use cases for hook_f_a_X() implementations will operate on a single given entity type, with a if ($entity_type == 'some_entity') {
wrapping the function inner code.
After #765860: drupal_alter() fails to order modules correctly in some cases, a hook_f_a_X_[entity_type]() variant would result in less no-op function calls.
No time to work on a patch for the next couple days, just creating the issue.
Comments
Comment #1
sunsubscribing
Comment #2
sunI guess you primarily mean _field_invoke() ?
Issue with that is that it's not using drupal_alter(). But I agree that this would be helpful for performance and code flow. We'd need to introduce a similar technique for module_invoke(), I guess.
That said, I always wondered why drupal_alter() is much more advanced than our module_invoke*() functions...
Comment #3
effulgentsia CreditAttribution: effulgentsia commentedSubscribing. Push the code in drupal_alter() that supports $type as an array into module_implements(), letting it support $hook as an array? Is there sufficient buy-in to get that into D7?
Comment #4
sunHow could that work out? Usually the code flow is like this:
or
The only location where it would make more sense to me is:
However, http://api.drupal.org/api/function/_field_invoke/7 is really far more than a simple module_invoke()...
If there was a module API function that would look and work like the following, then it would start to make sense:
LOL ;)
Comment #5
sunLooks like we want to tackle module_implements() in the same way as drupal_alter() as early as possible in D8 :)
Comment #6
fagosubscribe
Comment #7
jhedstromI think this has been reworked entirely. See https://www.drupal.org/node/2193813.