Nette\DI\Container::hasService PHP Метод

hasService() публичный Метод

Does the service exist?
public hasService ( $name ) : boolean
Результат boolean
    public function hasService($name)
    {
        $name = isset($this->meta[self::ALIASES][$name]) ? $this->meta[self::ALIASES][$name] : $name;
        return isset($this->registry[$name]) || method_exists($this, $method = self::getMethodName($name)) && (new \ReflectionMethod($this, $method))->getName() === $method;
    }

Usage Example

Пример #1
0
 /**
  * getter for specified model
  *
  * @param string $name name of model
  * @return BaseModel
  * @throws \InvalidArgumentException
  */
 public function getModel($name)
 {
     if ($this->container->hasService($name)) {
         return $this->container->getService($name);
     }
     throw new \InvalidArgumentException("Model '{$name}' not found.");
 }
All Usage Examples Of Nette\DI\Container::hasService