esn-cy / esn-activities-api
Package info
github.com/esn-cy/ESN-Activities-API
Type:drupal-module
pkg:composer/esn-cy/esn-activities-api
Requires
- php: ^8.3
- esn-cy/omnia: ^1.8
- phpdocumentor/reflection-docblock: ^5.2 || ^6.0
- symfony/property-access: ^6.4 || ^7.0 || ^8.0
- symfony/property-info: ^6.4 || ^7.0 || ^8.0
Requires (Dev)
- drupal/core-dev: ^10.3 || ^11
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-01 00:10:24 UTC
README

ESN Activities API
A Drupal module that connects with the Erasmus Generation API to fetch activity data and automatically synchronise it into Drupal content entities.
Features
- Custom Entities: Defines Enum-backed custom content entities for
Activity,Cause, andSDG. - Background Synchronization: Utilises Drupal's Queue API and Queue Workers to process API pagination in the background without causing PHP timeouts.
- Dual-Sync Modes:
- Fast Sync: Runs frequently to fetch recently modified or created activities.
- Full Sync: Runs periodically to guarantee historical consistency.
- Smart Data Mapping: Intelligently maps deeply nested DTOs (Data Transfer Objects) to Drupal fields, including physical locations, external links, timestamps, and taxonomy references.
- Self-Healing: Automatically handles API downtime by leveraging Queue exceptions to requeue failed pages.
Dependencies
This module relies on the following custom ESN modules:
esn_accounts_api(Provides theOrganisationentity)omnia(ProvidesOmniaSettings)
(Ensure your project's composer.json includes the packages.esn.org repository to resolve these dependencies).
Installation
- Require the module via Composer or place it in your
modules/customdirectory. - Enable the module via the Drupal UI or using Drush:
drush en esn_activities_api
- Drupal will automatically install the necessary database tables for the Activity, Cause, and SDG entities.
Configuration
Navigate to Omnia > ESN Activities API Settings (/admin/config/system/esn-activities-api) to configure the module:
- Enable Sync: Toggle the synchronisation engine on or off.
- Global Mode: Determines whether to sync all activities globally or filter them by your National Organization's Country Code (set up in Omnia Settings).
- API Key: The authentication key for the Erasmus Generation API.
- Sync Intervals: Configure how often the Fast Sync and Full Sync cutoff timestamps are calculated.
- Manual Triggers: Use the manual trigger buttons to instantly push a Fast or Full sync job to the queue.
Architecture
The synchronisation process is entirely decoupled and automated:
CronService: Hooked into Drupal's cron. It evaluates your configured intervals, calculates the correct timestamp cutoffs, and pushes an initial payload to theesn_activities_api_syncqueue.SyncWorker(QueueWorker): Processes the queue item in the background.- It calls the
EndpointServiceto fetch a specific page from the remote API. - It passes the deserialized
ActivityDTOobjects to theActivityImporterService. - If the API returns more items, the worker creates a new queue item for
page + 1to process the next batch.
- It calls the
ActivityImporterService: Checks if the remote activity was modified since the last sync. If so, it maps all data, handles relationalCauseandSDGcreations, and persists the Drupal entities.