<?php

namespace AutoAdmin\Bundle\Seo\DependencyInjection\Compiler;

use AutoAdmin\Bundle\Seo\Schema\SchemaManager;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

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