function Drupal::service
Retrieves a service from the container.
@template T of object
Parameters
class-string<T>|string $id: The ID of the service to retrieve.
Return value
($id is class-string<T> ? T : object) The specified service.
891 calls to Drupal::service()
- AccessRoleTest::testRenderCaching in core/
modules/ user/ tests/ src/ Functional/ Views/ AccessRoleTest.php - Tests access on render caching.
- 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.
- ActiveWorkspaceUpdateTest::testActiveWorkspaceDuringUpdate in core/
modules/ workspaces/ tests/ src/ Functional/ UpdateSystem/ ActiveWorkspaceUpdateTest.php - Tests that there is no active workspace during database updates.
- AddedStylesheetsTest::testCkeditorStylesheets in core/
modules/ ckeditor5/ tests/ src/ Functional/ AddedStylesheetsTest.php - Test the ckeditor5-stylesheets theme config.
File
-
core/
lib/ Drupal.php, line 204
Class
- Drupal
- Static Service Container wrapper.
Code
public static function service(string $id) : object {
return static::getContainer()->get($id);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.