Complete Event System Mapping¶
Generated: December 15, 2025
Total EventSubscribers: 2
Total EventListeners: 8
Status: Complete
SUMMARY¶
Event System Components¶
- EventSubscribers: 2
- EventListeners: 8
- Doctrine Event Listeners: 0
- Entity Lifecycle Callbacks: 0
Automation-Triggering Events¶
- Events that dispatch MessageBus commands: 1
MessageConsumedEvent(handled by MessageConsumedHandler)
EVENT SUBSCRIBERS¶
1. MessageConsumedHandler AUTOMATION-CRITICAL¶
File: src/MessageBus/MessageConsumedHandler.php
Events Subscribed:
- WorkerMessageHandledEvent - After a message handler completes
Purpose: ENABLES COMMAND CHAINING
This is the core infrastructure that enables MessageBus command chaining. When a command completes, this subscriber:
1. Checks if the command has chained commands (withChain())
2. Dispatches the next command in the chain
3. Handles both chainable and non-chainable commands
4. Removes processed messages from the database
Dispatch Locations: 3 - Line 125: Dispatch chained commands (dynamic) - Line 128: Dispatch non-chainable commands (dynamic) - Line 134: Dispatch final command in chain (dynamic)
Impact on Automation:
CRITICAL - Without this subscriber, ALL command chaining would fail. This is what allows:
- KpnSp16ImportCommand → PupeteerKpnSp16SyncCommand → DispatchTotalsCommand → DispatchTotalsBackupCommand
- RoutitInvoiceCommand → CalculateTotalsCommand → BillingInsightTotalsCommand → SaveStatusCommand
- All other multi-command automation chains
2. LogCrmApiV2Subscriber LOGGING ONLY¶
File: src/EventSubscriber/LogCrmApiV2Subscriber.php
Events Subscribed:
- KernelEvents::CONTROLLER - Before controller execution
- KernelEvents::RESPONSE - After response is created
Purpose: Logs all CRM API V2 requests and responses
Methods:
- onKernelController() - Creates log entry with endpoint, parameters, user, IP
- onKernelResponse() - Updates log entry with response status code
Automation Impact: None (logging infrastructure only)
EVENT LISTENERS¶
All EventListeners are infrastructure components and do NOT trigger automation.
1. AuthenticationFailureListener¶
File: src/EventListener/AuthenticationFailureListener.php
Event: lexik_jwt_authentication.on_authentication_failure
Priority: 0
Purpose: Handles JWT authentication failures for main app
Automation Impact: None
2. AuthenticationSuccessListener¶
File: src/EventListener/AuthenticationSuccessListener.php
Event: lexik_jwt_authentication.on_authentication_success
Priority: 0
Purpose: Handles JWT authentication success for main app
Automation Impact: None
3. CrmAuthenticationFailureListener¶
File: src/EventListener/CrmAuthenticationFailureListener.php
Event: lexik_jwt_authentication.on_authentication_failure
Priority: 1
Purpose: Handles JWT authentication failures for CRM API
Automation Impact: None
4. CrmAuthenticationSuccessListener¶
File: src/EventListener/CrmAuthenticationSuccessListener.php
Event: lexik_jwt_authentication.on_authentication_success
Priority: 1
Purpose: Handles JWT authentication success for CRM API
Automation Impact: None
5. CrmJWTCreatedListener¶
File: src/EventListener/CrmJWTCreatedListener.php
Event: lexik_jwt_authentication.on_jwt_created
Purpose: Customizes JWT payload when token is created for CRM API
Automation Impact: None
6. CrmJWTDecodedListener¶
File: src/EventListener/CrmJWTDecodedListener.php
Event: lexik_jwt_authentication.on_jwt_decoded
Purpose: Validates JWT token when decoded for CRM API
Automation Impact: None
7. LocaleListener¶
File: src/EventListener/LocaleListener.php
Event: kernel.request
Purpose: Sets locale from request for internationalization
Automation Impact: None
8. LoggedUserCookieListener¶
File: src/EventListener/LoggedUserCookieListener.php
Event: kernel.response
Purpose: Sets cookie with logged user information
Automation Impact: None
DOCTRINE EVENT SYSTEM¶
Doctrine Event Listeners: 0
Doctrine Event Subscribers: 0
Entity Lifecycle Callbacks: 0
Finding: No Doctrine-level event automation detected.
AUTOMATION FLOW DIAGRAM¶
┌─────────────────────────────────────────────────────────────────┐
│ EVENT-DRIVEN AUTOMATION │
└─────────────────────────────────────────────────────────────────┘
1. Command dispatched to MessageBus
└─> Handler processes command
└─> Handler completes
└─> WorkerMessageHandledEvent fired
└─> MessageConsumedHandler::onWorkerMessageHandled()
│
├─> Check if command has chain
│ │
│ ├─> YES: Dispatch next command in chain
│ │ └─> LOOP: Process continues recursively
│ │
│ └─> NO: Remove message from database
│
└─> End
Example Chain Execution:
User triggers: kpn:sp16:scrape console command
↓
KpnSp16SyncCommand dispatched
↓
KpnSp16SyncHandler processes
↓
Dispatches KpnSp16ImportCommand with chain:
- PupeteerKpnSp16SyncCommand
- DispatchTotalsCommand
- DispatchTotalsBackupCommand
↓
WorkerMessageHandledEvent fired
↓
MessageConsumedHandler detects chain
↓
Dispatches KpnSp16ImportCommand (first in chain)
↓
[Recursive chain processing continues...]
VERIFICATION COMMANDS¶
Verify EventSubscribers:
Expected: 2 filesVerify EventListeners:
Expected: 8 filesVerify automation-triggering listeners:
for file in src/EventListener/*.php src/EventSubscriber/*.php; do
echo "$file: $(grep -c 'dispatch(' $file 2>/dev/null || echo 0)"
done
KEY FINDINGS¶
1. Minimal Event-Driven Architecture¶
- Only 1 event triggers automation (WorkerMessageHandledEvent)
- All other events are infrastructure (auth, logging, cookies, locale)
- No Doctrine entity events used for automation
2. Command Chaining is Event-Driven¶
- MessageConsumedHandler is the ONLY automation-triggering event subscriber
- It enables the entire command chaining infrastructure
- Without it, all multi-step automations would fail
3. No Custom Events¶
- No custom Event classes defined
- No EventDispatcher usage found
- System relies entirely on Symfony Messenger + Kernel events
4. Separation of Concerns¶
- Authentication/Authorization: 6 listeners (JWT-related)
- Logging: 1 subscriber (CRM API V2)
- Internationalization: 1 listener (Locale)
- Automation: 1 subscriber (MessageConsumedHandler)
VERIFICATION STATUS¶
- EventSubscribers Found: 2/2 100%
- EventListeners Found: 8/8 100%
- Automation-Triggering Events: 1/1 100%
- Doctrine Events: 0/0 100%
- Infrastructure Events: 9/9 100%
Last Updated: Mon Dec 15 10:40:00 CET 2025