Drupal::hasService

public static Drupal::hasService($id)

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.

File

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

Class

Drupal
Static Service Container wrapper.

Code

1
2
3
4
public static function hasService($id) {
  // Check hasContainer() first in order to always return a Boolean.
  return static::hasContainer() && static::getContainer()->has($id);
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.