Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Drupal.php

function Drupal::service

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.

323 calls to Drupal::service()
Action::create in core/modules/system/src/Entity/Action.php
Constructs a new entity object, without permanently saving it.
Action::getPluginCollection in core/modules/system/src/Entity/Action.php
Encapsulates the creation of the action's LazyPluginCollection.
AssetResolver::getJsAssets in core/lib/Drupal/Core/Asset/AssetResolver.php
Returns the JavaScript assets for the current response's libraries.
AssetResolver::__construct in core/lib/Drupal/Core/Asset/AssetResolver.php
Constructs a new AssetResolver instance.
authorize.php in core/authorize.php
Administrative script for running authorized file operations.

... See full list

File

core/lib/Drupal.php, line 196

Class

Drupal
Static Service Container wrapper.

Code

public static function service($id) {
    return static::getContainer()->get($id);
}
RSS feed
Powered by Drupal