<?php
namespace Tionvel\ImporterBundle;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class TionvelImporterBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new class implements CompilerPassInterface {
public function process(ContainerBuilder $container)
{
$registry = $container->getDefinition('tionvel.importer_bundle.importer.importer_executor');
foreach ($container->findTaggedServiceIds('tionvel_importer') as $id => $tags) {
$registry->addMethodCall('addImporter', [$tags[0]['key'] ?? uniqid(), new Reference($id)]);
}
}
});
}
}