Issue #2250243 by dawehner, sun: Remove needless ContainerAware dependency from AuthenticationManager.
parent
62edf5212d
commit
a704796c30
|
@ -856,6 +856,8 @@ services:
|
||||||
- { name: needs_destruction }
|
- { name: needs_destruction }
|
||||||
authentication:
|
authentication:
|
||||||
class: Drupal\Core\Authentication\AuthenticationManager
|
class: Drupal\Core\Authentication\AuthenticationManager
|
||||||
|
tags:
|
||||||
|
- { name: service_collector, tag: authentication_provider, call: addProvider }
|
||||||
authentication_subscriber:
|
authentication_subscriber:
|
||||||
class: Drupal\Core\EventSubscriber\AuthenticationSubscriber
|
class: Drupal\Core\EventSubscriber\AuthenticationSubscriber
|
||||||
tags:
|
tags:
|
||||||
|
|
|
@ -57,18 +57,19 @@ class AuthenticationManager implements AuthenticationProviderInterface, Authenti
|
||||||
/**
|
/**
|
||||||
* Adds a provider to the array of registered providers.
|
* Adds a provider to the array of registered providers.
|
||||||
*
|
*
|
||||||
* @param string $provider_id
|
|
||||||
* Identifier of the provider.
|
|
||||||
* @param \Drupal\Core\Authentication\AuthenticationProviderInterface $provider
|
* @param \Drupal\Core\Authentication\AuthenticationProviderInterface $provider
|
||||||
* The provider object.
|
* The provider object.
|
||||||
|
* @param string $id
|
||||||
|
* Identifier of the provider.
|
||||||
* @param int $priority
|
* @param int $priority
|
||||||
* The providers priority.
|
* The providers priority.
|
||||||
*/
|
*/
|
||||||
public function addProvider($provider_id, AuthenticationProviderInterface $provider, $priority = 0) {
|
public function addProvider(AuthenticationProviderInterface $provider, $id, $priority = 0) {
|
||||||
$provider_id = substr($provider_id, strlen('authentication.'));
|
// Remove the 'authentication.' prefix from the provider ID.
|
||||||
|
$id = substr($id, 15);
|
||||||
|
|
||||||
$this->providers[$provider_id] = $provider;
|
$this->providers[$id] = $provider;
|
||||||
$this->providerOrders[$priority][$provider_id] = $provider;
|
$this->providerOrders[$priority][$id] = $provider;
|
||||||
// Force the builders to be re-sorted.
|
// Force the builders to be re-sorted.
|
||||||
$this->sortedProviders = NULL;
|
$this->sortedProviders = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ use Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass;
|
||||||
use Drupal\Core\DependencyInjection\Compiler\RegisterKernelListenersPass;
|
use Drupal\Core\DependencyInjection\Compiler\RegisterKernelListenersPass;
|
||||||
use Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass;
|
use Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass;
|
||||||
use Drupal\Core\DependencyInjection\Compiler\RegisterServicesForDestructionPass;
|
use Drupal\Core\DependencyInjection\Compiler\RegisterServicesForDestructionPass;
|
||||||
use Drupal\Core\DependencyInjection\Compiler\RegisterAuthenticationPass;
|
|
||||||
use Drupal\Core\Plugin\PluginManagerPass;
|
use Drupal\Core\Plugin\PluginManagerPass;
|
||||||
use Drupal\Core\Site\Settings;
|
use Drupal\Core\Site\Settings;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
@ -69,9 +68,6 @@ class CoreServiceProvider implements ServiceProviderInterface {
|
||||||
$container->addCompilerPass(new ListCacheBinsPass());
|
$container->addCompilerPass(new ListCacheBinsPass());
|
||||||
$container->addCompilerPass(new CacheContextsPass());
|
$container->addCompilerPass(new CacheContextsPass());
|
||||||
|
|
||||||
// Add the compiler pass that will process tagged authentication services.
|
|
||||||
$container->addCompilerPass(new RegisterAuthenticationPass());
|
|
||||||
|
|
||||||
// Register plugin managers.
|
// Register plugin managers.
|
||||||
$container->addCompilerPass(new PluginManagerPass());
|
$container->addCompilerPass(new PluginManagerPass());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Contains \Drupal\Core\DependencyInjection\Compiler\RegisterAuthenticationPass.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Drupal\Core\DependencyInjection\Compiler;
|
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds services tagged 'authentication_provider'.
|
|
||||||
*/
|
|
||||||
class RegisterAuthenticationPass implements CompilerPassInterface {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds authentication providers to the authentication manager.
|
|
||||||
*
|
|
||||||
* Check for services tagged with 'authentication_provider' and add them to
|
|
||||||
* the authentication manager.
|
|
||||||
*
|
|
||||||
* @see \Drupal\Core\Authentication\AuthenticationManager
|
|
||||||
* @see \Drupal\Core\Authentication\AuthenticationProviderInterface
|
|
||||||
*/
|
|
||||||
public function process(ContainerBuilder $container) {
|
|
||||||
if (!$container->hasDefinition('authentication')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Get the authentication manager.
|
|
||||||
$matcher = $container->getDefinition('authentication');
|
|
||||||
// Iterate all autentication providers and add them to the manager.
|
|
||||||
foreach ($container->findTaggedServiceIds('authentication_provider') as $id => $attributes) {
|
|
||||||
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
|
|
||||||
$matcher->addMethodCall('addProvider', array(
|
|
||||||
$id,
|
|
||||||
new Reference($id),
|
|
||||||
$priority,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue