<?php

namespace AutoAdmin\Bundle\Seo\DependencyInjection\Compiler;

use AutoAdmin\Bundle\Seo\Extractor\ExtractorManager;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

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