AuthenticationProviderPass example

    $container->addCompilerPass(new RegisterEventSubscribersPass(), PassConfig::TYPE_AFTER_REMOVING);

    $container->addCompilerPass(new RegisterAccessChecksPass());

    // Add a compiler pass for registering services needing destruction.     $container->addCompilerPass(new RegisterServicesForDestructionPass());

    // Add the compiler pass that will process the tagged services.     $container->addCompilerPass(new ListCacheBinsPass());
    $container->addCompilerPass(new CacheContextsPass());
    $container->addCompilerPass(new ContextProvidersPass());
    $container->addCompilerPass(new AuthenticationProviderPass());

    // Register plugin managers.     $container->addCompilerPass(new PluginManagerPass());

    $container->addCompilerPass(new DeprecatedServicePass());

  }

  /** * Alters the UUID service to use the most efficient method available. * * @param \Drupal\Core\DependencyInjection\ContainerBuilder $container * The container builder. */
$definition->addTag('authentication_provider', ['provider_id' => 'llama_auth', 'priority' => 100]);
    $definition->addTag('_provider', ['provider' => 'test_provider_a']);
    $definition->setPublic(TRUE);
    $container->setDefinition('test_provider_a.authentication.llama_auth', $definition);

    $definition = new Definition('TestClass');
    $definition->addTag('authentication_provider', ['provider_id' => 'camel_auth', 'priority' => -100]);
    $definition->addTag('_provider', ['provider' => 'test_provider_b']);
    $definition->setPublic(TRUE);
    $container->setDefinition('test_provider_b.authentication.camel_auth', $definition);

    $compiler_pass = new AuthenticationProviderPass();
    $compiler_pass->process($container);

    $this->assertEquals(['bunny_auth' => 'test_provider_a', 'llama_auth' => 'test_provider_a', 'camel_auth' => 'test_provider_b']$container->getParameter('authentication_providers'));
  }

}
Home | Imprint | This part of the site doesn't use cookies.