<?php


namespace AutoAdmin\Bundle\Admin\DependencyInjection\Compiler;


use AutoAdmin\Bundle\Admin\Configuration\ConfigBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class ExtraConfigCompilerPass implements CompilerPassInterface
{
    /**
     * @inheritDoc
     */
    public function process(ContainerBuilder $container)
    {
        $extraConfigServicesArg = [];
        $extraConfigServices = $container->findTaggedServiceIds('aa_admin.extra_config');
        foreach ($extraConfigServices as $id => $value) {
            $extraConfigServicesArg[] = new Reference($id);
        }
        $def = $container->getDefinition(ConfigBuilder::class);
        $def->setArgument('$extraConfigProcessors', $extraConfigServicesArg);
    }
}