Skip to content

Architecture

Andreas Michael edited this page Dec 2, 2026 · 2 revisions

Architecture

The ESN Membership Manager (esn_membership_manager) is a modular Drupal 10/11 module built on top of the Omnia (esn-cy/omnia) foundation. This page documents its core entities, database schema, services, stream wrapper, action plugins, and background jobs.

Core Entities

Both primary domain objects are fieldable Drupal Content Entities extending Omnia's EnumBackedEntityBase:

Entity ID Class Base Table Storage / Access Handlers
membership_application Drupal\esn_membership_manager\Entity\Application\Application membership_application ApplicationStorage, ApplicationAccess
membership_guest Drupal\esn_membership_manager\Entity\GuestPass\GuestPass membership_guest GuestPassStorage, GuestPassAccess
  • Field Enums:

    ApplicationField and GuestPassField define typed field metadata, read-only rules (based on email/ID/status verification), and ESNcard-exclusive flags.

  • Cascade Clean-up (postDelete):

    Deleting an Application automatically deletes its private files, associated GuestPass entities, Stripe Payment Link, Google Wallet passes, Apple Wallet device registrations, and authentication tokens.

Custom Database Tables

Defined in esn_membership_manager.install:

Table Purpose
esn_membership_manager_cards Inventory pool of physical ESNcard numbers (id, number, assigned).
esn_membership_manager_in_progress_applications Temporary state for in-progress registrations (email, Didit session/results, ESN Accounts CAS results).
esn_membership_manager_authentication 8-digit one-time email verification codes with expiration timestamps (register/login).
esn_membership_manager_apple_wallet_registrations iOS device registrations (device_library_identifier, serial_number, push_token) for Apple Wallet APNs push updates.

Services

Registered in esn_membership_manager.services.yml:

  • esn_membership_manager.esncard_service (ESNcardService):

    Validates and inserts ESNcard inventory, assigns cards transactionally (SELECT ... FOR UPDATE), manages BACKLOGGED / BACKLOGGED-MANUAL queues, and executes post-assignment hooks (Weeztix, Google Sheets, Wallet links, email).

  • esn_membership_manager.guest_pass_service (GuestPassService):

    Evaluates Instant Limit and Special Mobility rules, creates Guest Pass entities, and triggers auto-approval when eligible.

  • esn_membership_manager.file_service (FileService):

    Manages private application files stored under the membership:// stream wrapper.

  • esn_membership_manager.cron_service (CronService):

    Delegates hook_cron() to GDPRCron.

  • esn_membership_manager.stripe_service (StripeService):

    Extends StripeServiceBase (Omnia) to create standard/ESNer payment links, verify webhook signatures, and fetch prices.

  • esn_membership_manager.didit_service (DiditService):

    Interfaces with Didit Verification API v3 (session,decision, delete, generate-pdf).

  • esn_membership_manager.weeztix_service (WeeztixService):

    Handles Weeztix OAuth2 token lifecycle andPUT /coupon/{listID}/codes syncing.

  • esn_membership_manager.google_service (GoogleService):

    Extends GoogleServiceBase (Omnia) for Google Auth, Google Sheets row appending, and Google Wallet Generic Classes/Objects (card, pass, guest).

  • esn_membership_manager.apple_wallet_service (AppleService):

    Extends AppleServiceBase (Omnia) for Sign in with Apple, .pkpass signing (ESNcard, FreePass, GuestPass), and APNs push notifications.

  • plugin.manager.membership_dashboard_section (DashboardSectionManager):

    Drupal DefaultPluginManager discovering #[DashboardSection] plugins under Plugin\DashboardSection for the Member Self-Service Dashboard.

Private File Storage (membership://)

  • Implemented by MembershipStreamWrapper (stream_wrapper.membership), storing files outside the web root in ../../private/esn_membership_manager_storage with a Deny from all .htaccess.
  • Protected by hook_file_download() and FileAccessController (/memberships/files/{applicationID}/{filename}), ensuring only authorised users (e.g., officers with view applications) can access uploaded IDs, proofs of status, and photos.

Action Plugins

Bulk and single-item status transitions are implemented as Drupal @Action plugins under src/Plugin/Action/:

  • esn_membership_manager_approve (ApproveApplication)
  • esn_membership_manager_reject (RejectApplication)
  • esn_membership_manager_delete (DeleteApplication)
  • esn_membership_manager_mark_paid (MarkApplicationAsPaid)
  • esn_membership_manager_issue (IssueCard)
  • esn_membership_manager_deliver (DeliverCard)
  • esn_membership_manager_blacklist (BlacklistApplication)
  • esn_membership_manager_approve_guest (ApproveGuestPass)

Dashboard Section Plugins

The Member Self-Service Dashboard (/memberships/dashboard) is assembled dynamically from PHP #[DashboardSection] attribute plugins under src/Plugin/DashboardSection/, managed by DashboardSectionManager:

  • application (ApplicationSection, weight 10) — Personal/mobility details, inline editing, and document re-uploads.
  • wallet (WalletSection, weight 20) — Google Wallet and Apple Wallet pass links.
  • guest (GuestPassSection, weight 30) — Active Guest Passes table and request form.

Companion modules can contribute additional sections, sidebar navigation entries, overview Quick Actions, and interactive form actions using the built-in UI builders. See Dashboard Extensions for the full developer guide.

Email Templates

Outgoing emails extend MembershipEmailBase and use Omnia's EmailService with Twig templates in templates/: PassConfirmationEmail, BothConfirmationEmail, PassApprovalEmail, BothApprovalEmail, RejectionEmail, CardAssignmentEmail, CardIssuanceEmail, BlacklistEmail, GuestPassApprovalEmail, BacklogEmail, and AuthenticationEmail.

GDPR Cron (GDPRCron)

Executed via esn_membership_manager_cron():

  • 14-day retention: Deletes StatusProofFileID and IdentityDocumentFileID files and nullifies their fields.
  • 1-year retention: Runs Application::postDelete() cleanup and anonymizes PII (Name, Surname, Email, DateOfBirth, FacePhotoFileID, payment links).

Clone this wiki locally