As you can see from the screenshot, ECA includes a bunch of submodules, each responsive for its functionality. Enable them as needed.
To handle ECA more effectively, we recommend installing the BPMNI.IO module. It provides an interface for building diagram flows. To install the BPMNI.IO module, write this line in composer:
composer require drupal/bpmn_io
The BPMN.iO interface looks like this:
This visual interface allows web developers to create workflow diagrams, as well as all team members to review them to get acquainted with the business logic of a particular workflow.
Event - Condition - Action Submodules
The ECA module package includes the following submodules:
- ECA Access: Events and actions to control access on entities and fields
- ECA Base: Base events, conditions and actions
- ECA Cache: Actions to read, write, or invalidate cache items
- ECA Config: Config events
- ECA Content: Content entity events, conditions, and actions
- ECA Endpoint: Events to define your own endpoint/routes on the fly and actions to interact with their requests and responses
- ECA Form: Form API events, conditions, and actions
- ECA Log: Events and actions for Drupal log messages
- ECA Migrate: Migrate events
- ECA Misc: Miscellaneous events and conditions from Drupal core and the kernel
ECA Queue: Events, conditions, and actions for queued operations.
- ECA Render: Events and actions to work with Drupal's render API for blocks, views, and all around themes and Twig
- ECA User: User events, conditions and actions
- ECA Views: Execute and export Views query results within ECA
- ECA Workflow: Content entity workflow actions
Enabling any of these submodules depends on what functionality your project requires. Carefully read the description of each to understand what ECA feature it is responsible for.
Building workflows with ECA Drupal module
As we have already mentioned above, the usage of the ECA module always comes together with the BPMN.IO, as BPMN.IO is a user-friendly interface used for the creation of visual workflows. Let’s create a workflow with Drupal Event - Condition - Action module together.
Go to ‘Configuration → Workflow → ECA’ in the admin panel. Click on ‘+ Add new model’ to create a new workflow in the BPMN.IO interface.
Here you can see a ‘toolbar’ for creating diagrams.
- Circle refers to Events.
- Diamond refers to Gateways (Gateways are used to combine multiple conditions, create chain Actions for an Event).
- Rectangle refers to Actions.
- Arrow refers to Conditions (arrows connect Events and Actions).
On the right side of the BPMN.IO interface, you can find another toolbar for ECA process management. It will be updated according to what element you’ve selected.
Let’s create a workflow to see ECA in work. Imagine we have a website with recipes. Any user can add a recipe to favorites. We want the author of the post to be notified via email when a user adds the recipe to favorites. The author needs to put a tick during node creation if he wants to be notified. The ECA for this workflow is as follows:
This workflow consists of the following elements:
- The event (Recipe added to favorite): triggers the workflow.
- The condition (field_notify_author = TRUE): checks if the author wants to be notified.
- Two chain actions: load the author of the node and notify him via email.
ECA also allows site builders to add comments to clarify certain elements of the workflow.
This was only a small example of ECA capabilities. Hopefully, this gave you a brief understanding of the Drupal Event - Condition - Action module and its potential for workflow development. You can find more detailed guidelines at ecaguide.org, a website created by the ECA dev team.
Summing Up
Event - Condition - Action is a powerful and highly flexible tool for creating workflows in Drupal. As this module was only released a few years ago, we can expect even more impressive functions to come shortly.
Drupfan, your trusted Drupal web development partner, is here to assist you with everything Drupal-related starting from workflow setup to building a site from the ground up. Reach out to us today to discuss your project in more detail.