• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/di/servicelocator.php
  • Класс: BitrixMainDIServiceLocator
  • Вызов: ServiceLocator::get
public function get(string $id)
{
	if (isset($this->instantiated[$id]))
	{
		return $this->instantiated[$id];
	}

	if (!isset($this->services[$id]))
	{
		throw $this->buildNotFoundException($id);
	}

	[$class, $args] = $this->services[$id];

	if ($class instanceof Closure)
	{
		$object = $class();
	}
	else
	{
		if ($args instanceof Closure)
		{
			$args = $args();
		}
		$object = new $class(...array_values($args));
	}

	$this->instantiated[$id] = $object;

	return $object;
}