W3cubDocs

/Drupal 8

public function CoreServiceProvider::register

public CoreServiceProvider::register(ContainerBuilder $container)

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 46

Class

CoreServiceProvider
ServiceProvider class for mandatory core services.

Namespace

Drupal\Core

Code

public function register(ContainerBuilder $container) {
  $this->registerUuid($container);
  $this->registerTest($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']);
  }

  // Add the compiler pass that lets service providers modify existing
  // service definitions. This pass must come first so that later
  // list-building passes are operating on the post-alter services list.
  $container->addCompilerPass(new ModifyServiceDefinitionsPass());

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

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

  $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 GuzzleMiddlewarePass());

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

  // Add a compiler pass for registering event subscribers.
  $container->addCompilerPass(new RegisterEventSubscribersPass(), PassConfig::TYPE_AFTER_REMOVING);

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

  // 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());

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

  $container->addCompilerPass(new DependencySerializationTraitPass());
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!CoreServiceProvider.php/function/CoreServiceProvider::register/8.1.x