function CoreServiceProvider::register
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/CoreServiceProvider.php \Drupal\Core\CoreServiceProvider::register()
- 10 core/lib/Drupal/Core/CoreServiceProvider.php \Drupal\Core\CoreServiceProvider::register()
- 9 core/lib/Drupal/Core/CoreServiceProvider.php \Drupal\Core\CoreServiceProvider::register()
- 8.9.x core/lib/Drupal/Core/CoreServiceProvider.php \Drupal\Core\CoreServiceProvider::register()
Registers services to the container.
Parameters
ContainerBuilder $container: The ContainerBuilder to register services to.
Overrides ServiceProviderInterface::register
File
-
core/
lib/ Drupal/ Core/ CoreServiceProvider.php, line 59
Class
- CoreServiceProvider
- ServiceProvider class for mandatory core services.
Namespace
Drupal\CoreCode
public function register(ContainerBuilder $container) {
// Only register the private file stream wrapper if a file path has been
// set.
if (Settings::get('file_private_path')) {
$container->register('stream_wrapper.private', 'Drupal\\Core\\StreamWrapper\\PrivateStream')
->addTag('stream_wrapper', [
'scheme' => 'private',
]);
}
$container->addCompilerPass(new HookCollectorPass());
$container->addCompilerPass(new ThemeHookCollectorPass());
$container->addCompilerPass(new HookCollectorKeyValueWritePass(), PassConfig::TYPE_OPTIMIZE);
// Add the compiler pass that lets service providers modify existing
// service definitions. This pass must come before all passes operating on
// services so that later list-building passes are operating on the
// post-alter services list.
$container->addCompilerPass(new ModifyServiceDefinitionsPass());
$container->addCompilerPass(new DevelopmentSettingsPass());
$container->addCompilerPass(new SuperUserAccessPolicyPass());
$container->addCompilerPass(new ProxyServicesPass());
$container->addCompilerPass(new BackendCompilerPass());
$container->addCompilerPass(new CorsCompilerPass());
$container->addCompilerPass(new StackedKernelPass());
$container->addCompilerPass(new StackedSessionHandlerPass());
$container->addCompilerPass(new MainContentRenderersPass());
// Collect tagged handler services as method calls on consumer services.
$container->addCompilerPass(new TaggedHandlersPass());
$container->addCompilerPass(new RegisterStreamWrappersPass());
$container->addCompilerPass(new TwigExtensionPass());
// Add a compiler pass for registering event subscribers.
$container->addCompilerPass(new RegisterEventSubscribersPass(new RegisterListenersPass()), PassConfig::TYPE_AFTER_REMOVING);
$container->addCompilerPass(new LoggerAwarePass(), 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 AuthenticationProviderPass());
// Register plugin managers.
$container->addCompilerPass(new PluginManagerPass());
$container->addCompilerPass(new DeprecatedServicePass());
// Collect moved classes for the backwards compatibility class loader.
$container->addCompilerPass(new BackwardsCompatibilityClassLoaderPass());
$container->registerForAutoconfiguration(EventSubscriberInterface::class)
->addTag('event_subscriber');
$container->registerForAutoconfiguration(LoggerAwareInterface::class)
->addTag('logger_aware');
$container->registerForAutoconfiguration(QueueFactoryInterface::class)
->addTag('queue_factory');
$container->registerForAutoconfiguration(PreWarmableInterface::class)
->addTag('cache_prewarmable');
$container->registerForAutoconfiguration(ModuleUninstallValidatorInterface::class)
->addTag('module_install.uninstall_validator');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.