esn-cy / esn-activities-api
Package info
github.com/esn-cy/ESN-Activities-API
Type:drupal-module
pkg:composer/esn-cy/esn-activities-api
v1.0.0
2026-08-02 11:52 UTC
Requires
- esn-cy/omnia: ^v1.3
- symfony/property-access: ^8.1
- symfony/property-info: ^8.1
Requires (Dev)
- drupal/core: ^10
This package is auto-updated.
Last update: 2026-08-02 11:56:54 UTC
README

ESN Activities API
A Drupal module that connects with the Erasmus Generation API to fetch activity data and automatically synchronize it into Drupal content entities.
Features
- Custom Entities: Defines Enum-backed custom content entities for
Activity,Cause, andSDG. - Background Synchronization: Utilizes 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 synchronization 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 synchronization 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.