You are here

private function ControllerBase::container in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::container()
  2. 9 core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::container()

Returns the service container.

This method is marked private to prevent sub-classes from retrieving services from the container through it. Instead, \Drupal\Core\DependencyInjection\ContainerInjectionInterface should be used for injecting services.

Return value

\Symfony\Component\DependencyInjection\ContainerInterface The service container.

10 calls to ControllerBase::container()
ControllerBase::cache in core/lib/Drupal/Core/Controller/ControllerBase.php
Returns the requested cache bin.
ControllerBase::config in core/lib/Drupal/Core/Controller/ControllerBase.php
Retrieves a configuration object.
ControllerBase::currentUser in core/lib/Drupal/Core/Controller/ControllerBase.php
Returns the current user.
ControllerBase::entityFormBuilder in core/lib/Drupal/Core/Controller/ControllerBase.php
Retrieves the entity form builder.
ControllerBase::entityTypeManager in core/lib/Drupal/Core/Controller/ControllerBase.php
Retrieves the entity type manager.

... See full list

File

core/lib/Drupal/Core/Controller/ControllerBase.php, line 290

Class

ControllerBase
Utility base class for thin controllers.

Namespace

Drupal\Core\Controller

Code

private function container() {
  return \Drupal::getContainer();
}