• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/tree.php
  • Класс: BitrixSaleLocationTree
  • Вызов: Tree::deleteExtended
static function deleteExtended($primary, array $additional = array()) // here also could be an implementation of CHILDREN_REATTACH
{
	$rebalance = !isset($additional['REBALANCE']) || $additional['REBALANCE'] !== false;
	$deleteSubtree = !isset($additional['DELETE_SUBTREE']) || $additional['DELETE_SUBTREE'] !== false;

	if($deleteSubtree)
	{
		// it means we want to delete not only the following node, but the whole subtree that belongs to it
		// note that with this option set to Y tree structure integrity will be compromised

		$node = self::getNodeInfo($primary);
		if(intval($node['ID']))
		{
			static::checkNodeThrowException($node);
			// low-level
			MainHttpApplication::getConnection()->query('delete from '.static::getTableName().' where LEFT_MARGIN > '.$node['LEFT_MARGIN'].' and RIGHT_MARGIN < '.$node['RIGHT_MARGIN']);

			// and also remove free spece, if needed
			if($rebalance)
			{
				self::manageFreeSpace(
					$node['RIGHT_MARGIN'],
					($node['RIGHT_MARGIN'] - $node['LEFT_MARGIN']) + 1,
					self::SPACE_REMOVE
				);
			}
		}
		else
		{
			throw new TreeNodeNotFoundException(false, array('INFO' => array('ID' => $primary)));
		}
	}

	return parent::delete($primary);
}