CoreFiles by mySites.guru
AddConstraintValidatorsPass.php50 lines, 1,552 bytes, from Joomla_6.0.2-Stable-Full_Package.zip
Raw History Compare with 6.0.1
md5
1069f403205fdc65b694c6df18139ce0
sha1
651f3a1eb0b96cf6bcf09a18ead7a2e1c69011c4
sha256
f9a20c1d83923c926c8bda3caa88c2b1ad013191b3ba6bc44460c3e7f1760f0c
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Validator\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
 * @author Johannes M. Schmitt <[email protected]>
 * @author Robin Chalas <[email protected]>
 */
class AddConstraintValidatorsPass implements CompilerPassInterface
{
    /**
     * @return void
     */
    public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition('validator.validator_factory')) {
            return;
        }

        $validators = [];
        foreach ($container->findTaggedServiceIds('validator.constraint_validator', true) as $id => $attributes) {
            $definition = $container->getDefinition($id);

            if (isset($attributes[0]['alias'])) {
                $validators[$attributes[0]['alias']] = new Reference($id);
            }

            $validators[$definition->getClass()] = new Reference($id);
        }

        $container
            ->getDefinition('validator.validator_factory')
            ->replaceArgument(0, ServiceLocatorTagPass::register($container, $validators))
        ;
    }
}

The same content is in 135 releases, Joomla 5.1.0-beta1 to 6.2.1. See them all, or every version of this file.