<?php

namespace KupShop\AutomationConfiguratorBundle;

use KupShop\AutomationConfiguratorBundle\Configurator\Interfaces\Actions\ActionInterface;
use KupShop\AutomationConfiguratorBundle\Configurator\Interfaces\Conditions\Fields\FieldInterface;
use KupShop\AutomationConfiguratorBundle\Configurator\Interfaces\Conditions\Groups\GroupInterface;
use KupShop\AutomationConfiguratorBundle\Configurator\Interfaces\Context\AutomationContextProvider;
use KupShop\AutomationConfiguratorBundle\Configurator\Interfaces\Triggers\TriggerInterface;
use KupShop\AutomationConfiguratorBundle\Configurator\Orders\Context\OrdersContextProvider;
use KupShop\AutomationConfiguratorBundle\Configurator\Orders\OrdersContext;
use KupShop\AutomationConfiguratorBundle\DependencyInjection\Compiler\InspectionPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class AutomationConfiguratorBundle extends Bundle
{
    public const LOG_TAG_AUTOPILOT = 'Autopilot';

    public function build(ContainerBuilder $container)
    {
        parent::build($container);

        $container->registerForAutoconfiguration(FieldInterface::class)
            ->addTag('kupshop.automationConfigurator.field')
            ->setPublic(false)
            ->setAutowired(true);

        $container->registerForAutoconfiguration(GroupInterface::class)
            ->addTag('kupshop.automationConfigurator.group')
            ->setPublic(false)
            ->setAutowired(true);

        $container->registerForAutoconfiguration(TriggerInterface::class)
            ->addTag('kupshop.automationConfigurator.trigger')
            ->setPublic(false)
            ->setAutowired(true);

        $container->registerForAutoconfiguration(ActionInterface::class)
            ->addTag('kupshop.automationConfigurator.action')
            ->setPublic(false)
            ->setAutowired(true);

        $container->registerForAutoconfiguration(AutomationContextProvider::class)
            ->addTag('kupshop.automationConfigurator.provider')
            ->setPublic(false)
            ->setAutowired(true);

        $container->registerForAutoconfiguration(OrdersContext::class)
            ->addTag('kupshop.automationConfigurator.context', ['context' => OrdersContextProvider::CONTEXT_NAME])
            ->setPublic(false)
            ->setAutowired(true);

        $container->addCompilerPass(new InspectionPass());
    }
}
