Optimize the loading of configured ECA items
Problem/Motivation
If I understand the current implementation right, then the following logic is currently happening:
- Something happens in the system (e.g. a hook is fired, like inserting a node)
- If existing, a Symfony event object is being instantiated that represents that concrete happening
- The ECA event subscriber, that is being registered for every ECA-related event, comes in and passes the given event to a Processor by calling an execute method
- Within the execute method, the Processor looks up all existing ECA configurations by loading them all and checks if any of those configurations apply for the given event
- Every configured ECA that applies is being started by calling its configured successors (which are actions, optionally in regard to a condition)
This might be causing performance issues, e.g. when having many configurations, that would be iterated over in a lot of places (i.e. events being fired up). The BPMN.io integration for example stores the visualized BPMN graph as an XML document string within the filename attribute of the ECA config, and this one might be a large document - but would be loaded any time an event fires up.
Proposed resolution
We might be able to separate the applies logic into two parts, in a manner that it may be checked first solely for the assigned event id (currently known as "drupal_id" or "drupal_event_class"). This way it might also be cached for subsequent HTTP requests, as the system would know which configured ECAs apply for a given event in general. After that lookup progress, all ECAs found in that first check can finally be checked against the current ECA configuration values, whether they apply for the given event.