Scheb\TwoFactorBundle\DependencyInjection\Compiler\ProviderCompilerPass::process PHP Метод

process() публичный Метод

Collect registered two-factor providers and register them.
public process ( ContainerBuilder $container )
$container Symfony\Component\DependencyInjection\ContainerBuilder
    public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition('scheb_two_factor.provider_registry')) {
            return;
        }
        $registryDefinition = $container->getDefinition('scheb_two_factor.provider_registry');
        $voterDefinition = $container->getDefinition('scheb_two_factor.security_voter');
        $taggedServices = $container->findTaggedServiceIds('scheb_two_factor.provider');
        $references = array();
        $providerNames = array();
        foreach ($taggedServices as $id => $attributes) {
            if (!isset($attributes[0]['alias'])) {
                throw new InvalidArgumentException('Tag "scheb_two_factor.provider" requires attribute "alias" to be set.');
            }
            $name = $attributes[0]['alias'];
            $references[$name] = new Reference($id);
            $providerNames[] = $name;
        }
        $registryDefinition->replaceArgument(3, $references);
        $voterDefinition->replaceArgument(1, $providerNames);
    }

Usage Example

 /**
  * @test
  * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
  */
 public function process_missingAlias_throwException()
 {
     $this->createServiceDefinition();
     $taggedServices = array('serviceId' => array(0 => array()));
     $this->stubContainerService($taggedServices);
     $this->compilerPass->process($this->container);
 }
ProviderCompilerPass