2

I have defined an action and want to trigger it from a hook.

We do not want to use the Rules module, because it is still buggy with Drupal 8. So, we cannot use rules_invoke_component().

What is the correct way to trigger an action? Do I need to construct a new Action object? Do I need a service? Is there documentation on that anywhere?

  • You must consider using the Business Rules module as it is a great alternative to Rules modules and it is quite stable for now. – Elie Masaad Apr 23 '19 at 3:07
2

This works:

$action = \Drupal::entityTypeManager()
  ->getStorage('action')
  ->load('send_mail');
if ($action) {
  $action->execute($entity);
}

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.