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

mitchell’s picture

Title: confirm file locations for hooks » Module Builder integration with Rules
Project: Rules » Module Builder
Category: support » feature
Issue tags: +rules integration

Moving and tagging.

joachim’s picture

Project: Module Builder » Rules
Category: feature » support
Issue tags: -rules integration

I 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.

mitchell’s picture

I 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!

The 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.

If you don't think you can help, just close it.

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.

joachim’s picture

Project: Rules » Module Builder
Component: Miscellaneous » Code
Category: support » feature
Issue tags: +rules integration

Ok fair enough. I didn't realize that was a tag used across other projects.

mitchell’s picture

@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

  • perfect output. I thought it would have made more sense to appear first just in my concept of a module.

-.module file

  • hook_help came in automatically. I thought this was nice at first, because it's not a hook I would have thought to use for an action, but I don't think it's standard.
  • hook_menu also came in automatically, but it isn't necessary.

-.rules.inc

  • hook_rules_action_info has a radically different output than the .module file and the -views.inc file I tested with hook_views_data. Those have fill in the blank / replace the dummy descriptive text, whereas rules.inc has a simple example of an already written action that I could have looked up on my own. rules_example.rules.inc would be a more helpful text. Obviously, that's a Rules issue, but any recommendations you could provide would be appreciated.
  • I had also expected to see a starter section for the action, but perhaps this will only be possible once we switch to the PSR-0 standard. Do you have any recommendation on how to get something like %module_action_TODOname included?

What was that issue in core about api.php files?

joachim’s picture

> 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.

mitchell’s picture

> 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.

joachim’s picture

15 function rules_example_rules_action_info() {
16 $actions = array(
17 // The base-level keys in the array are the machine names for the actions,
18 // and by default also the function name for the action callback. Prefix
19 // with your module name to avoid name conflicts.
20 'rules_example_action_hello_world' => array(

Right, 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.

joachim’s picture

Status: Active » Postponed
joachim’s picture

Project: Module Builder » Rules
Component: Code » Documentation
Status: Postponed » Active

There is now a documentation standard for documenting callbacks. Module Builder supports this, so it's now up to Rules to document its callbacks.

TR’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

There 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.