You are here

public static function Drupal::hasService in Service Container 7

Same name and namespace in other branches
  1. 7.2 lib/Drupal.php \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.

3 calls to Drupal::hasService()
ServiceContainerIntegrationTest::testInit in lib/Drupal/service_container/Tests/ServiceContainerIntegrationTest.php
Tests some basic
ServiceContainerSymfonyTest::testInit in modules/providers/service_container_symfony/lib/Drupal/service_container_symfony/Tests/ServiceContainerSymfonyTest.php
Tests some basic
ServiceContainerSymfonyTest::testMultiple in modules/providers/service_container_symfony/lib/Drupal/service_container_symfony/Tests/ServiceContainerSymfonyTest.php
Tests with multiple modules enabled.

File

lib/Drupal.php, line 64
Contains Drupal 7 foreward compatibility layer for Drupal 8.

Class

Drupal
Static Service Container wrapper.

Code

public static function hasService($id) {

  // @todo Add ->has method to the container to be compatible.
  return static::$container && static::$container
    ->hasDefinition($id);
}