function Drupal::hasService

Indicates if a service is defined in the container.

Parameters

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

Return value

bool TRUE if the specified service exists, FALSE otherwise.

25 calls to Drupal::hasService()
Connection::dispatchEvent in core/lib/Drupal/Core/Database/Connection.php
Dispatches a database API event via the container dispatcher.
Database::getDriverList in core/lib/Drupal/Core/Database/Database.php
Returns the list provider for available database drivers.
DatabaseDriver::load in core/lib/Drupal/Core/Extension/DatabaseDriver.php
Loads the main extension file, if any.
EntityForm::getCallableFromDefinition in core/lib/Drupal/Core/Entity/EntityForm.php
Gets a callable from a string or array definition if possible.
ExtensionDiscovery::scan in core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
Discovers available extensions of a given type.

... See full list

File

core/lib/Drupal.php, line 217

Class

Drupal
Static Service Container wrapper.

Code

public static function hasService($id) {
  // Check hasContainer() first in order to always return a Boolean.
  return static::hasContainer() && static::getContainer()->has($id);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.