- Add comprehensive health check system with multiple endpoints - Add Prometheus metrics endpoint - Add production logging configurations (5 strategies) - Add complete deployment documentation suite: * QUICKSTART.md - 30-minute deployment guide * DEPLOYMENT_CHECKLIST.md - Printable verification checklist * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference * production-logging.md - Logging configuration guide * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation * README.md - Navigation hub * DEPLOYMENT_SUMMARY.md - Executive summary - Add deployment scripts and automation - Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment - Update README with production-ready features All production infrastructure is now complete and ready for deployment.
71 lines
1.6 KiB
PHP
71 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\LiveComponents;
|
|
|
|
use App\Framework\LiveComponents\ValueObjects\ComponentEvent;
|
|
use App\Framework\LiveComponents\ValueObjects\EventPayload;
|
|
|
|
/**
|
|
* Event Dispatcher for LiveComponents
|
|
*
|
|
* Components can use this to dispatch events during action execution.
|
|
* Events are collected and returned in the ComponentUpdate.
|
|
*/
|
|
final class ComponentEventDispatcher
|
|
{
|
|
/** @var array<ComponentEvent> */
|
|
private array $events = [];
|
|
|
|
/**
|
|
* Dispatch a broadcast event (to all components)
|
|
*/
|
|
public function dispatch(string $eventName, ?EventPayload $payload = null): void
|
|
{
|
|
$this->events[] = ComponentEvent::broadcast($eventName, $payload);
|
|
}
|
|
|
|
/**
|
|
* Dispatch a targeted event (to specific component)
|
|
*/
|
|
public function dispatchTo(string $eventName, string $targetComponentId, ?EventPayload $payload = null): void
|
|
{
|
|
$this->events[] = ComponentEvent::target($eventName, $targetComponentId, $payload);
|
|
}
|
|
|
|
/**
|
|
* Add a ComponentEvent directly
|
|
*/
|
|
public function add(ComponentEvent $event): void
|
|
{
|
|
$this->events[] = $event;
|
|
}
|
|
|
|
/**
|
|
* Get all dispatched events
|
|
*
|
|
* @return array<ComponentEvent>
|
|
*/
|
|
public function getEvents(): array
|
|
{
|
|
return $this->events;
|
|
}
|
|
|
|
/**
|
|
* Clear all events (used after processing)
|
|
*/
|
|
public function clear(): void
|
|
{
|
|
$this->events = [];
|
|
}
|
|
|
|
/**
|
|
* Check if any events were dispatched
|
|
*/
|
|
public function hasEvents(): bool
|
|
{
|
|
return ! empty($this->events);
|
|
}
|
|
}
|