Let's add support for basic event settings, such that often needed event filters can be applied to events. That's more efficient than running conditions later on + enables new use-cases for embedding event configuration there as needed for fluxkraft.

Use cases:
- React on node presave and filter on type == page
- React on commerce order checkout and filter on the default bundle
- React on twitter stream with search "drupal" (fluxkraft)

Development is done in the "event_settings" branch.

Comments

fago’s picture

StatusFileSize
new19.22 KB

Here is a first not yet complete patch.

fago’s picture

Status: Needs work » Needs review
StatusFileSize
new43.94 KB

Here is a first complete patch. It should be fully working, but misses some test cases for the new functionality.

API changes:

  • The RulesTriggerableInterface has changed, i.e. getEventSettings() has been added, event() and events() slight modified.
  • The RulesReactionRule class has been changed to fit the above changes.

This API changes only affect module that come with their own variant of a rules reaction rule plugin, or another sort of triggerable plugin. I'm not aware of any module having something like that, nor could I think of a good reason for doing so right now, so I don't think that API change should be a big deal.

fago’s picture

StatusFileSize
new45.21 KB

Ok, added a test case.

fubhy’s picture

Status: Needs review » Needs work

There is still a bug here... The rules_empty_events variable is now written with the computed event set name and not the event base name which causes our fluxkraft event sets to always end up in the empty events array because event name != base event name.

fubhy’s picture

Or do I have to fire the event with the computed event set name now? I guess I have to... Hmm... Then it makes sense I guess

fubhy’s picture

I still think it's note QUITE right though... But I'll let you figure that out ;P

fubhy’s picture

When creating a new Rule with an Event that exposes settings the event does NOT get added to the rule after hitting save. However, it always works to configure and save an event on a rule that already exists.

fago’s picture

Or do I have to fire the event with the computed event set name now? I guess I have to... Hmm... Then it makes sense I guess

Exactly. However, with the current patch we end up with a cache-lookup for each configurable event. So let's better follow the approach of #1555634: Improve performance of event cache by moving to a whitelist and add a cache item that maintains an index of configured-event-set-names.

fago’s picture

Status: Needs work » Needs review
StatusFileSize
new50.93 KB
new23.17 KB

ok, updated the patch to account for the problems. Also renamed event settings handler to event handler so we can use it for further event related functionality (dispatcher) also. Also added docs and fixed invocation order to match what we do with entity hooks.

Execution works as it is now, but should be optimised using #1555634: Improve performance of event cache by moving to a whitelist.

fago’s picture

Status: Needs review » Fixed

this fits the requirements of #2023519: Add support for task handlers and event dispatchers. and generally seems do its job just fine, thus committed.

fago’s picture

Change notice created: https://drupal.org/node/2024257

Automatically closed -- issue fixed for 2 weeks with no activity.