Is there a way to programmatically create a Rules component?

I mean a component like the ones listed on /admin/config/workflow/rules/components.

  • Did you refer to the docs or API for Rules? – Kevin Nov 19 '17 at 16:16
  • Unfortunately, I haven't found how it in the docs for Rules. And even in the module sources. I found how to create a rule. But about creating of components - I haven't. – Yakimkin Roman Nov 19 '17 at 18:28
  • cgit.drupalcode.org/rules/tree/rules.api.php#n494 "component: If set to TRUE, the rules admin UI will list elements of those plugin in the components UI and allows the creation of new components based upon this plugin. Optional." – Kevin Nov 19 '17 at 19:06

Rule components can be programmatically created- although they can be quite cumbersome to code from scratch. I'd recommend building a component with some conditions, actions, and rulesets and exporting it. Then you can analyze the exported php to determine how to define your custom component set.

You'll most likely want to reference:

  1. A list of the hooks available for the D7 version of the Rules module can be found here: http://www.drupalcontrib.org/api/drupal/contributions%21rules%21rules.api.php/group/rules_hooks/7

  2. A good set of Developer Documentation for custom rules (albeit an old set of documentation for the D6 version of Rules) can be found here: https://www.drupal.org/node/298486

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.