You are here

public function Container::has in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/dependency-injection/Container.php \Symfony\Component\DependencyInjection\Container::has()
  2. 8.0 core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::has()
Same name and namespace in other branches
  1. 8 vendor/symfony/dependency-injection/Container.php \Symfony\Component\DependencyInjection\Container::has()

Returns true if the given service is defined.

Parameters

string $id The service identifier:

Return value

bool true if the service is defined, false otherwise

Overrides ContainerInterface::has

File

vendor/symfony/dependency-injection/Container.php, line 218

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');
    }
  }
}