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 have written a RulesAction. That works great.
Now I want to execute this Rule from Code.
In Detail I want to call a menu route and execute my custom RulesAction.
The menu route is defined in the same custom module and extends from ControllerBase.
But how to invoke the RuleAction?
In Drupal 7 there was the rules_invoke_component() Methode.
Comments
Comment #2
zhiqiang.qiu CreditAttribution: zhiqiang.qiu commentedsame question? anyone can help? I'm not sure, it should be like this?
Comment #3
wombatbuddy CreditAttribution: wombatbuddy commentedHere is the documentation that can clarify something:
https://www.drupal.org/docs/8/modules/d8-rules-essentials/for-developers...
https://www.drupal.org/docs/8/modules/d8-rules-essentials/for-developers
Comment #4
TR CreditAttribution: TR commented#2 was answered by #3.
For the original post, the best answer to "how do I do X programmatically" is always going to be "look at the test cases". Everything in Rules has tests, and these contain working examples of how to use every feature.
Here's a modified version of DataConvertTest to show you how this works. You may save this script and execute it with
drush php:script