task_api ECA model ⭐¶
Source: web/modules/contrib/fedms_eca/config/optional/eca.eca.task_api.yml
Purpose: The heart of the FedMS workflow. This model walks the
fedms_task_pattern registry and spawns fedms_task instances when
group or membership lifecycle events fire — driven by the
field_flag_start_processed / field_flag_end_processed flags on
event and session groups, plus user-add events on every group level.
This is the model you will touch most often when adjusting FedMS workflow behavior. Read carefully before editing.
Events the model listens to¶
The model has a large set of events. The most important:
| Event plugin | Label |
|---|---|
content_entity:insert (group_relationship event-group_membership) |
Add user to an event |
content_entity:insert (group_relationship session-group_membership) |
Add user to a session |
content_entity:insert (group_relationship org-group_membership) |
Add user to an organization |
eca_base:eca_cron |
Cron — re-evaluate lifecycle flags |
And a large number of custom condition events:
| Plugin | Used for |
|---|---|
fedms_task_pattern_condition |
Is group an event? Is group a session? Check event type. Check session type. Check user role. Check org/event/session group role. |
fedms_task_pattern_condition_arguments |
Event type arguments. Session type arguments. Check role arguments. Check org/event/session group role arguments. |
The custom plugins live in fedms_task/src/Plugin/ECA/Event/ and are
referenced from the model's events: section.
How a task is spawned (mental model)¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
Entities & contexts touched¶
group(bundlesorg,event,session)group_relationship(membership additions trigger the_insertevents)fedms_task_pattern(config — read to decide what to spawn)fedms_task(content — created)taxonomy_term(fedms_task_milestone) — referenced by spawned tasks
Custom condition plugins¶
The conditions used by task_api are all event plugins under
fedms_task/src/Plugin/ECA/Event/. They dispatch a Symfony event
that the corresponding action plugin
(CreateTaskFromPattern) listens to and uses to short-circuit
pattern evaluation.
| Plugin id (event-id) | What it checks |
|---|---|
fedms_task_pattern_is_event |
Is the affected group an event? |
fedms_task_pattern_is_session |
Is the affected group a session? |
fedms_task_pattern_check_event_type |
Does the event's bundle match the argument? |
fedms_task_pattern_check_session_type |
Does the session's bundle match the argument? |
fedms_task_pattern_check_user_role |
Does the user have the given site role? |
fedms_task_pattern_check_user_org_group_role |
Does the user have a given role in the parent org? |
fedms_task_pattern_check_user_event_group_role |
Same for the parent event. |
fedms_task_pattern_check_user_session_group_role |
Same for sessions. |
Each _condition event has a matching _condition_arguments event
that provides the arguments from the pattern's conditionArguments
field.
How lifecycle flags drive bulk processing¶
Two fields on the event and session group entities drive lifecycle processing:
field_flag_start_processed—FALSEuntil the start window has passed and the start tasks have spawned. Set toTRUEonce processed.field_flag_end_processed— same for the end of the window.
The view views.view.groups_unprocessed selects all events and
sessions whose flags are still unprocessed and whose date window has
passed. Cron walks this view and triggers the relevant branches of
task_api.
Don't flip these flags manually unless you fully understand the
side-effects — flipping a flag back to FALSE will cause tasks to
spawn again.
Editing notes / gotchas¶
- Successors form chains, not graphs. Avoid creating cycles in
fedms_task_pattern.successors[]. There is no cycle-breaker. - Milestones are referenced by UUID, not by ID — see
TaskPattern::milestoneEntity(). Don't refactor that to numeric IDs without updating every pattern'smilestone:value. - Custom condition plugins are PHP, not ECA-only. If you change their signatures or behavior, run the PHP tests:
1 2 | |
- Org-level patterns use
task_createtimestamps only. SeeTaskPattern::getTimestamp()— it short-circuits to "now" forbundle === 'org'regardless of the pattern'sactionableRelation. This is deliberate. - The model has many branches. Use the modeler's visual view to understand it; the raw YAML has ~2,400 lines and is not human-friendly.
- Bulk imports can produce lots of tasks. Be careful when adding a pattern with broad conditions on a high-membership event.
Related issues¶
Active issues against task_api and the task engine:
fedms/components/tasks#5— Variations of task completion.fedms/components/tasks#11— Task rule when members are removed.fedms/components/tasks#15— Task rule when other tasks are completed (successors).fedms/components/tasks#20— Prevent ambiguous task/webform relationship.fedms/components/tasks#22— "One of" content groups in task patterns.fedms/components/tasks#24— Dynamic due dates.fedms/components/tasks#26— Successor tasks for embedded objects.
See also¶
fedms_task/src/Entity/TaskPattern.php— the config entity.fedms_task/src/Entity/Task.php— the content entity.fedms_task/src/Plugin/Action/CreateTaskFromPattern.php— the action that does the spawning.fedms_task/src/Plugin/ECA/Event/— the custom condition plugins.- event_groups, session_groups — provide the form-side flag manipulation that this model consumes.
- milestone_views — surfaces the spawned tasks in Views.