4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Validator\DependencyInjection;
14 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15 use Symfony\Component\DependencyInjection\ContainerBuilder;
16 use Symfony\Component\DependencyInjection\Reference;
19 * @author Fabien Potencier <fabien@symfony.com>
20 * @author Robin Chalas <robin.chalas@gmail.com>
22 class AddValidatorInitializersPass implements CompilerPassInterface
24 private $builderService;
25 private $initializerTag;
27 public function __construct($builderService = 'validator.builder', $initializerTag = 'validator.initializer')
29 $this->builderService = $builderService;
30 $this->initializerTag = $initializerTag;
33 public function process(ContainerBuilder $container)
35 if (!$container->hasDefinition($this->builderService)) {
39 $initializers = array();
40 foreach ($container->findTaggedServiceIds($this->initializerTag, true) as $id => $attributes) {
41 $initializers[] = new Reference($id);
44 $container->getDefinition($this->builderService)->addMethodCall('addObjectInitializers', array($initializers));