Skip to content

feature/add-tenant-db-lifecycle-events#78

Merged
RamyHakam merged 2 commits intomasterfrom
feature/add-tenant-db-lifecycle-events
Feb 14, 2026
Merged

feature/add-tenant-db-lifecycle-events#78
RamyHakam merged 2 commits intomasterfrom
feature/add-tenant-db-lifecycle-events

Conversation

@RamyHakam
Copy link
Owner

This pull request introduces a new set of tenant lifecycle events to the multi-tenancy bundle and integrates them into key command and listener classes. These events provide hooks for external systems to react to important tenant database actions, such as creation, migration, bootstrapping, deletion, and switching. The changes enhance the extensibility and observability of tenant operations by dispatching events at appropriate stages.

New Tenant Lifecycle Events

  • Added six new event classes to encapsulate tenant lifecycle actions: AbstractTenantEvent (base class), TenantCreatedEvent, TenantBootstrappedEvent, TenantMigratedEvent, TenantDeletedEvent, and TenantSwitchedEvent. These events include metadata and context for each action. [1] [2] [3] [4] [5] [6]

Command Integration

  • Updated CreateDatabaseCommand, MigrateCommand, and LoadTenantFixtureCommand to dispatch the new events (TenantCreatedEvent, TenantMigratedEvent, and TenantBootstrappedEvent) after successfully creating databases, running migrations, or loading fixtures, respectively. This allows external listeners to react to these lifecycle milestones. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Database Switch Event Integration

  • Enhanced DbSwitchEventListener to dispatch a TenantSwitchedEvent after successfully switching the active tenant database connection, including information about the previous tenant for auditing and analytics. [1] [2] [3] [4]

Dependency Injection Updates

  • Modified service definitions in services.xml to inject the event dispatcher into relevant command and listener services, enabling event dispatching functionality. [1] [2]

Event Usage Preparation

  • Added import for TenantDeletedEvent in DbService.php to prepare for future integration of deletion event dispatching.

@RamyHakam RamyHakam self-assigned this Feb 12, 2026
@RamyHakam RamyHakam added the enhancement New feature or request label Feb 12, 2026
@RamyHakam RamyHakam added the v3 label Feb 14, 2026
@RamyHakam RamyHakam merged commit 05fd662 into master Feb 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant