* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Reference; /** * Adds all services with the tag "form.field_factory_guesser" as argument * to the "form.field_factory" service * * @author Bernhard Schussek */ class AddFieldFactoryGuessersPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { if (!$container->hasDefinition('form.field_factory')) { return; } $guessers = array_map(function($id) { return new Reference($id); }, array_keys($container->findTaggedServiceIds('form.field_factory.guesser'))); $container->getDefinition('form.field_factory')->replaceArgument(0, $guessers); } }