• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/component.php
  • Класс: CBitrixComponent
  • Вызов: CBitrixComponent::initComponent
public function initComponent($componentName, $componentTemplate = false)
{
	$this->__bInited = false;

	$componentName = trim($componentName);
	if ($componentName == '')
	{
		$this->__ShowError("Empty component name");
		return false;
	}

	$path2Comp = CComponentEngine::MakeComponentPath($componentName);
	if ($path2Comp == '')
	{
		$this->__ShowError(sprintf("'%s' is not a valid component name", $componentName));
		return false;
	}

	$componentPath = getLocalPath("components".$path2Comp);
	$this->classOfComponent = self::__getClassForPath($componentPath);

	if($this->classOfComponent === "")
	{
		$componentFile = $_SERVER["DOCUMENT_ROOT"].$componentPath."/component.php";
		if (!file_exists($componentFile) || !is_file($componentFile))
		{
			$this->__ShowError(sprintf("'%s' is not a component", $componentName));
			return false;
		}
	}

	self::increaseComponentCounter($componentName);
	$this->__currentCounter = self::$__componentCounter[$componentName];

	$this->__name = $componentName;
	$this->__relativePath = $path2Comp;
	$this->__path = $componentPath;
	$this->arResult = array();
	$this->arParams = array();
	$this->__parent = null;
	$this->__arIncludeAreaIcons = array();
	$this->__cache = null;
	if ($componentTemplate !== false)
		$this->__templateName = $componentTemplate;

	$this->__bInited = true;

	return true;
}