<?php

declare(strict_types=1);

namespace KupShop\AutomationConfiguratorBundle\Util;

use KupShop\AutomationConfiguratorBundle\Event\TriggerEvent;
use KupShop\AutomationConfiguratorBundle\Logger\ActivityLogLogger;
use KupShop\KupShopBundle\Util\Logging\Initiator;
use KupShop\KupShopBundle\Util\Logging\LoggerInfoHelper;

class ConfigurationsUtil
{
    public function __construct(
        private readonly ConfigurationsRunner $configurationsRunner,
        private readonly ActivityLogLogger $activityLogLogger,
        private LoggerInfoHelper $loggerInfoHelper,
    ) {
    }

    public function runTrigger(TriggerEvent $event): void
    {
        $this->configurationsRunner->setLogger($this->activityLogLogger);
        $this->loggerInfoHelper->activateInitiator(Initiator::Autopilot,
            function () use ($event) {
                $this->configurationsRunner->run($event);
            }
        );
    }
}
