RegisterLdapLocatorPass.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler;
  11. use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
  12. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. use Symfony\Component\DependencyInjection\Definition;
  15. use Symfony\Component\DependencyInjection\Reference;
  16. use Symfony\Component\DependencyInjection\ServiceLocator;
  17. /**
  18. * @author Wouter de Jong <wouter@wouterj.nl>
  19. *
  20. * @internal
  21. */
  22. class RegisterLdapLocatorPass implements CompilerPassInterface
  23. {
  24. public function process(ContainerBuilder $container)
  25. {
  26. $definition = $container->setDefinition('security.ldap_locator', new Definition(ServiceLocator::class));
  27. $locators = [];
  28. foreach ($container->findTaggedServiceIds('ldap') as $serviceId => $tags) {
  29. $locators[$serviceId] = new ServiceClosureArgument(new Reference($serviceId));
  30. }
  31. $definition->addArgument($locators);
  32. }
  33. }