• Модуль: translate
  • Путь к файлу: ~/bitrix/modules/translate/lib/index/internals/pathindex.php
  • Класс: BitrixTranslateIndexInternalsPathIndexTable
  • Вызов: PathIndexTable::onAfterAdd
static function onAfterAdd(ORMEvent $event): ORMEventResult
{
	$result = new ORMEventResult();
	$primary = $event->getParameter('primary');
	$data = $event->getParameter('fields');

	if (isset($primary['ID'], $data['PARENT_ID']))
	{
		$nodeId = $primary['ID'];
		$parentId = $data['PARENT_ID'];
		$tableName = PathTreeTable::getTableName();
		$connection = MainApplication::getConnection();
		$connection->query("
			INSERT INTO {$tableName} (PARENT_ID, PATH_ID, DEPTH_LEVEL)
			SELECT PARENT_ID, '{$nodeId}', DEPTH_LEVEL + 1 FROM {$tableName} WHERE PATH_ID = '{$parentId}'
			UNION ALL 
			SELECT '{$nodeId}', '{$nodeId}', 0
		");
	}

	return $result;
}