You are here

public function Container::has in Service Container 7

Same name in this branch
  1. 7 lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::has()
  2. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Container.php \Symfony\Component\DependencyInjection\Container::has()
Same name and namespace in other branches
  1. 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Container.php \Symfony\Component\DependencyInjection\Container::has()

Returns true if the given service is defined.

@api

Parameters

string $id The service identifier:

Return value

bool true if the service is defined, false otherwise

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Container.php, line 238

Class

Container
Container is a dependency injection container.

Namespace

Symfony\Component\DependencyInjection

Code

public function has($id) {
  for ($i = 2;;) {
    if ('service_container' === $id || isset($this->aliases[$id]) || isset($this->services[$id]) || array_key_exists($id, $this->services)) {
      return true;
    }
    if (--$i && $id !== ($lcId = strtolower($id))) {
      $id = $lcId;
    }
    else {
      return method_exists($this, 'get' . strtr($id, $this->underscoreMap) . 'Service');
    }
  }
}