8.5.x Drupal.php Drupal::service($id)
8.0.x Drupal.php Drupal::service($id)
8.1.x Drupal.php Drupal::service($id)
8.2.x Drupal.php Drupal::service($id)
8.3.x Drupal.php Drupal::service($id)
8.4.x Drupal.php Drupal::service($id)
8.6.x Drupal.php Drupal::service($id)

Retrieves a service from the container.

Use this method if the desired service is not one of those with a dedicated accessor method below. If it is listed below, those methods are preferred as they can return useful type hints.

Parameters

string $id: The ID of the service to retrieve.

Return value

mixed The specified service.

2 calls to Drupal::service()
content_moderation_node_access in core/modules/content_moderation/content_moderation.module
Implements hook_node_access().
_drupal_maintenance_theme in core/includes/theme.maintenance.inc
Sets up the theming system for maintenance page.

File

core/lib/Drupal.php, line 157
Contains \Drupal.

Class

Drupal
Static Service Container wrapper.

Code

public static function service($id) {
  return static::getContainer()
    ->get($id);
}