<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Symfony\Bundle\DependencyInjection\Compiler;

use DH\Auditor\Provider\Doctrine\Persistence\Event\CreateSchemaListener;
use DH\Auditor\Provider\Doctrine\Persistence\Command\UpdateSchemaCommand;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

final class AuditorCommandPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container): void
    {
        if (!$container->hasDefinition(UpdateSchemaCommand::class)) {
            return;
        }

        $container->getDefinition(UpdateSchemaCommand::class)->clearTag('console.command');

        if ($container->hasDefinition(CreateSchemaListener::class)) {
            $container->getDefinition(CreateSchemaListener::class)->clearTag('doctrine.event_listener');
        }
    }
}
