• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/component_util.php
  • Класс: CComponentUtil
  • Вызов: CComponentUtil::GetNamespaceList
static function GetNamespaceList()
{
	$arNamespaces = array();
	$folders = array(
		"/local/components",
		"/bitrix/components",
	);

	foreach($folders as $componentFolder)
	{
		if(file_exists($_SERVER["DOCUMENT_ROOT"].$componentFolder))
		{
			if ($handle = opendir($_SERVER["DOCUMENT_ROOT"].$componentFolder))
			{
				while (($file = readdir($handle)) !== false)
				{
					if ($file == "." || $file == "..")
						continue;

					if (
						is_dir($_SERVER["DOCUMENT_ROOT"].$componentFolder."/".$file)
						&& !CComponentUtil::isComponent($componentFolder."/".$file)
					)
					{
						$arNamespaces[] = $file;
					}
				}
				closedir($handle);
			}
		}
	}

	return array_unique($arNamespaces);
}