<?php

namespace AutoAdmin\Bundle\Seo\DependencyInjection\Compiler;

use AutoAdmin\Bundle\Seo\Generator\GeneratorManager;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class GeneratorCompilerPass implements CompilerPassInterface
{
    /**
     * @inheritDoc
     */
    public function process(ContainerBuilder $container)
    {
        $serviceArguments = [];
        $tagged = $container->findTaggedServiceIds('aa_seo.generator');
        foreach ($tagged as $id => $value) {
            $serviceArguments[] = new Reference($id);
        }
        $def = $container->getDefinition(GeneratorManager::class);
        $def->setArgument('$generators', $serviceArguments);
    }
}