Event Condition Action

ECA - New rules engine for Drupal 9+

Jürgen Haas

25 Juni 2022

About us

Agenda

  1. Introduction
  2. Objectives
  3. Quick Demo
  4. ECA Architecture
  5. Modeller
  6. Full Demo
  7. Roadmap

Introduction

For a huge customer project, which eventually started to migrate from Drupal 7 to 9, we faced the problem that the old site heavily used the Rules module - and repeated research convinced us that Rules wasn’t ready for the job.

Neither custom code nor hard-coded business logic was on.

It was time to consider a brand-new approach!

Status of the famous Rules module

The Rules module for Drupal 8 is still in its alpha release stage … still needs significant work. (Excerpt description tr_rulez)

Previously

Early feedback to our prototype

Early feedback to our prototype

Early feedback to our prototype

Early feedback to our prototype

Objectives

=>

ECA got started to provide a “Rules” equivalent for Drupal 9 and beyond.

While getting close to deliver on that objective, ECA solves additional challenges and helps to trim-down the overhead of each Drupal application.

Reduce the need for custom modules

Far less likely your site needs a custom module for …

  • most of the hooks
  • form altering, validation or submit handlers
  • specific needs for cron or queue tasks

Reduce number of modules

Make a few helper modules redundant, like e.g. …

Transparency for business owners

Provide a tool where stakeholders who understand their business logic, but not necessarily Drupal details, can participate in building and maintaining the configuration throughout the lifecycle of the Drupal application.

Solid workflow

At the same time, Drupal CMI helps to track all the changes. In the future, we may even be able to support revisions and moderation, so that rock-solid workflows can be applied when needed.

Quick Demo

ECA Architecture

  • ECA is a processor - Period!
    No more, no less
  • Event subscribers listen to all Drupal events and trigger the ECA processor
  • ECA executes all available models that contain any of those events
  • ECA models are config entities

Where does the config come from?

ECA doesn’t care!

What components does the processor support?

  • Events: all Drupal events - you can add custom events
  • Conditions: ECA provides a plugin manager
  • Actions: all Drupal actions - you can add custom actions

Gateways, as a kind of extended conditions is also supported, not fully functional yet.

What’s already included in ECA?

  • Processor for ECA config entities with all contained rules
  • Plugin managers for modellers, events and conditions
  • Interfaces and abstract base classes and traits
  • Integration of all actions from Drupal core actions module
  • Support for caching, loops, logging, states, tokens, etc.
  • Prevent recursion
  • TypedData support
  • Tests, tests and tests

13 + 2 Submodules

  • ECA Access
    control access on entities and fields
  • ECA Base
    context, cron, custom, state, token, etc.
  • ECA Cache
    read, write or invalidate cache items
  • ECA Config
    listen, read & write config
  • ECA Content
    entities, fields, token, etc.
  • ECA Form
    build, validate, submit, etc.
  • ECA Log
    create and listen
  • ECA Migrate
    listen to all migrate events
  • ECA Misc
    kernel, Drupal core, routing, etc.
  • ECA Queue
    task queue, scheduled tasks, etc.
  • ECA User
    login, logout, cancel, switch, roles, etc.
  • ECA Views
    query, export, etc.
  • ECA Workflow
    transitions, etc.

  • ECA UI
  • ECA Develop

2 special submodules

ECA UI provides access to the ECA admin interface and to embedded modellers. Just like views and fields in core, their ui components can be turned off as well. This is useful for production sites where you want to utilize those APIs but have no need to modify such critical configuration.

ECA Develop comes with a couple of Drush commands and code generators. They are needed only under special circumstances. That’s why this can be enabled and disabled as required.

Contrib modules supporting ECA

Preparing support for more contrib

Modeller

  • A modeller is the user interface for ECA config entities.
  • It can be integrated as a @EcaModeller plugin, that stores models as config entities. The plugin manager is provided by the ECA module.
  • May be BPMN but not necessarily. Only the structure Event - Condition - Action matters.
  • Two modellers are already integrated:

Camunda Desktop Client

Download

Integrated by Camunda BPMN module.

BPMN.iO

Integrated in Drupal UI. Everything is provided by BPMN.iO module.

More information

Structure: Modeller

Possible modellers

Full Demo

Roadmap

Code Analysis

ECA

Directories: 111
Files: 358
Lines of Code: 41.889
Comment Lines of Code: 31%
Non-Comment Lines of Code: 69%

224 tests / 3.100 assertions
Coverage: 94% files / 83% lines

BPMN.IO

Directories: 1
Files: 2
Lines of Code: 148
Comment Lines of Code: 28%
Non-Comment Lines of Code: 72%

Code Style: all clean

All components tested on Drupal 9.3, 9.4, 10.x with PHP 7.4, 8.1

Team effort: approx. 3.000 hours

Releases

First commit 22nd July 2021

Beta-1 on 3rd November 2021
Beta-2 on 12th January 2022
Beta-3 on 17th March 2022
Beta-4 on 19th March 2022
Beta-5 on 21st March 2022
Beta-6 on 23rd March 2022
Beta-7 on 29th March 2022
Beta-8 on 12th April 2022
Beta-9 on 19th April 2022
Beta-10 on 20th April 2022
Beta-11 on 4th May 2022
Beta-12 on 17th May 2022

1.0.0-RC1 22nd June 2022
1.0.0 22nd July 2022

What’s next?

  • ECA defining and responding to routes
  • ECA defining custom forms
  • ECA for blocks
  • ECA for render arrays
  • Debugging models
  • Refactoring (code climate and performance)
  • Leveraging integration into more contrib modules
  • More modellers?
  • Support, documentation, model libraries and video tutorials

Modules and Issue Queues

Any help is highly appreciated

  • Development
    • ECA and plugins
    • Optimization of the integrated BPMN.iO client
  • Tests
  • Review and feedback
  • Support (Issue queue and in chats)
  • Documentation
  • Translations
  • Descriptions on the drupal.org project pages
  • Spread the word
  • Join us on Drupal Slack

Thanks - Q&A



Started as a rules engine for Drupal 9 …

… landing in the world of Low code - no code

ECA helps Drupal reaching new territory!