W3cubDocs

/Drupal 8

public static function 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

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal.php/function/Drupal::hasService/8.1.x