• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/checklist/checklistfacade.php
  • Класс: BitrixTasksCheckListCheckListFacade
  • Вызов: CheckListFacade::getArrayStructuredRoots
static function getArrayStructuredRoots(array $sourceArray, $keyToParent = 'PARENT_ID')
{
	$roots = [];
	$result = [];

	foreach ($sourceArray as $id => $item)
	{
		if (!isset($sourceArray[$id]['SUB_TREE']))
		{
			$sourceArray[$id]['SUB_TREE'] = [];
		}

		if ($item[$keyToParent] && isset($sourceArray[$item[$keyToParent]]))
		{
			$sourceArray[$item[$keyToParent]]['SUB_TREE'][$id] =& $sourceArray[$id];
		}
		else
		{
			$roots[] = $id;
		}
	}

	foreach ($roots as $root)
	{
		$result[$root] = $sourceArray[$root];
	}

	return $result;
}