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.
I'm adding support for file locations for Rules hooks to module builder.
Can you fill in any gaps in what I have so far please?
'rules' => array(
'hook_destinations' => array(
'%module.rules.inc' => array(
'hook_rules_action_info',
),
'%module.rules_default.inc' => array(
'hook_default_rules_configuration',
),
),
),
PS. If you have any thoughts on how this sort of information could be added in a parsable way to api.php files, I think there's a core issue open on it :)
Comments
Comment #1
mitchell CreditAttribution: mitchell commentedMoving and tagging.
Comment #2
joachim CreditAttribution: joachim commentedI put this in the Rules issue queue so Rules users or developers could help me with the missing information.
Nobody is going to notice it over here!
If you don't think you can help, just close it.
Comment #3
mitchell CreditAttribution: mitchell commentedThe Rules issue queue is already filled to the brim, so your issue probably isn't getting the attention you were looking for with this strategy. That tag is the way that other projects coordinate their rules integration with Rules users and developers, and I have seen overlap across issue queues from the eyeballs you're looking for.
I'm more of a Rules issue queue maintainer than code support responder. I still think that other Module Builder / Rules users can help with this issue, and I would like to see that happen because I've been a fan of your module for a long time.
I think, overall, this issue combines feature and support requests, which confused me. It comes off as the issue for developing code within module builder, yet also includes a question specific to Rules' file locations. Then, you also reference a relevant, yet unidentified issue about parsing api.php files. I think if you sort out these details, then these issues will progress nicely and won't need to be closed prematurely.
Comment #4
joachim CreditAttribution: joachim commentedOk fair enough. I didn't realize that was a tag used across other projects.
Comment #5
mitchell CreditAttribution: mitchell commented@joachim: I tried checking over the list of available hooks in admin/modules/module_builder as best as I could to see if everything was parsed, and it seemed right. I couldn't think of any other plugins in contrib with extensible Rules integration worth checking, but I'll keep any eye out to help for that and anything else that can be done to make Rules more usable with Module Builder. I think this module is very relevant to #1203886: Remove the PHP module from Drupal core (as demonstrated in rules issues like: #1479526: Action: modulus, ceiling, floor (rounding) and #1415628: How to: make data variables available for calculations).
Here's a small review I just did to create a simple Rules addon, having something simple like theme_rules in mind:
-.info file
-.module file
-.rules.inc
What was that issue in core about api.php files?
Comment #6
joachim CreditAttribution: joachim commented> hook_rules_action_info has a radically different output than the .module file and the -views.inc file I tested with hook_views_data
The function body for generated hooks is taken from, in turn:
- code in a .template file in module builder itself
- code in the hook definition in your module's *.api.php file
I would suggest you either update the api.php file, or if you don't feel that's appropriate, submit a patch for module builder :)
> I had also expected to see a starter section for the action
Can you clarify more about this? Is the action in a callback function or a class? Those aren't generated by module builder at all, though it's something I'd like to do.
Comment #7
mitchell CreditAttribution: mitchell commented> I would suggest you either update the api.php file, or if you don't feel that's appropriate, submit a patch for module builder :)
Yep, I opened #1612638: rules.api.php? to look into this.
> Can you clarify more about this? Is the action in a callback function or a class? Those aren't generated by module builder at all, though it's something I'd like to do.
I think the action is in a callback function that is defined in the info hook, but I could be misinterpreting the code. Would there be a way to setup a function block like, module name + _action_ + "name_your_action_here"? rules_example's hello_world' is an example with near-sample text.
Comment #8
joachim CreditAttribution: joachim commentedRight, so it's a callback.
There's no support for callbacks right now. It would be great if there were, but for that to happen there would need to be a standard way of defining callbacks in MODULE.api.php, which would need to include data about how a hook implementation (the rules_example_rules_action_info() function) causes a callback to be required and how to generate its name.
See #1250500: [policy adopted; patch done] Find a (standard) way to document callback signatures for the first part of that at least.
Comment #9
joachim CreditAttribution: joachim commentedComment #10
joachim CreditAttribution: joachim commentedThere is now a documentation standard for documenting callbacks. Module Builder supports this, so it's now up to Rules to document its callbacks.
Comment #11
TR CreditAttribution: TR commentedThere are several issue raised here. But after five years I still see no Rules integration in any version of module_builder, and the documentation issues raised in the latter part of this thread seem to be at least partially addressed for the D7 version of Rules (and irrelevant for the D8 version of Rules because we don't use hook callbacks in D8).
Regardless, if there is still a problem, please open a new issue with current information.