File: /home/xedaptot/ai.naniguide.com/app/Providers/AutomationRuntimeServiceProvider.php
<?php
namespace App\Providers;
use App\Domain\Automation\Enum\NodeType;
use App\Domain\Automation\Runtime\FlowExecutor;
use App\Domain\Automation\Runtime\HandlerRegistry;
use App\Domain\Automation\Runtime\Handlers\ConditionHandler;
use App\Domain\Automation\Runtime\Handlers\OperationHandler;
use App\Domain\Automation\Runtime\Handlers\SendHandler;
use App\Domain\Automation\Runtime\Handlers\WaitHandler;
use App\Domain\Automation\Runtime\Handlers\WaitUntilHandler;
use App\Domain\Automation\Runtime\Handlers\WebhookHandler;
use App\Domain\Automation\Runtime\CronTriggerScanner;
use App\Domain\Automation\Runtime\TriggerDispatcher;
use Illuminate\Support\ServiceProvider;
/**
* Wires the automation runtime: HandlerRegistry as singleton with one
* concrete NodeHandler bound per non-trigger NodeType, and FlowExecutor
* resolved with that registry.
*
* Trigger nodes don't need a handler — dispatching enters the flow at the
* trigger's CHILD, so the trigger itself is never executed.
*/
final class AutomationRuntimeServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->singleton(HandlerRegistry::class, function () {
$r = new HandlerRegistry();
$r->register(NodeType::Send, $this->app->make(SendHandler::class));
$r->register(NodeType::Wait, $this->app->make(WaitHandler::class));
$r->register(NodeType::WaitUntil, $this->app->make(WaitUntilHandler::class));
$r->register(NodeType::Condition, $this->app->make(ConditionHandler::class));
$r->register(NodeType::Operation, $this->app->make(OperationHandler::class));
$r->register(NodeType::Webhook, $this->app->make(WebhookHandler::class));
return $r;
});
$this->app->bind(FlowExecutor::class, function ($app) {
return new FlowExecutor($app->make(HandlerRegistry::class));
});
$this->app->bind(TriggerDispatcher::class, function ($app) {
return new TriggerDispatcher($app->make(FlowExecutor::class));
});
$this->app->bind(CronTriggerScanner::class, function ($app) {
return new CronTriggerScanner($app->make(TriggerDispatcher::class));
});
}
}