- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/location/connector.php
- Класс: BitrixSaleLocationConnector
- Вызов: Connector::checkConnectionExists
static function checkConnectionExists($entityPrimary, $locationPrimary, array $behaviour = array('LOCATION_LINK_TYPE' => 'ID'))
{
$entityPrimary = Assert::expectStringNotNull($entityPrimary, '$entityPrimary');
$locationPrimary = Assert::expectStringNotNull($locationPrimary, '$locationPrimary');
if(!isset($behaviour['LOCATION_LINK_TYPE']))
{
$behaviour['LOCATION_LINK_TYPE'] = 'ID';
}
else
{
$behaviour['LOCATION_LINK_TYPE'] = Assert::expectEnumerationMember($behaviour['LOCATION_LINK_TYPE'], array('AUTO', 'ID', 'CODE'), '$behaviour[LOCATION_LINK_TYPE]');
}
if(!static::checkLinkUsageAny($entityPrimary)) // if there are no links at all, connection virtually exists
{
return true;
}
if($behaviour['LOCATION_LINK_TYPE'] == 'AUTO')
{
$field = static::getUseCodes() ? 'CODE' : 'ID';
}
else
{
$field = $behaviour['LOCATION_LINK_TYPE'];
}
$node = LocationTable::getList(
array(
'filter' => array('='.$field => $locationPrimary),
'select' => array('ID', 'LEFT_MARGIN', 'RIGHT_MARGIN'),
'limit' => 1
)
)->fetch();
if(!intval($node['ID']))
{
throw new BitrixSaleLocationTreeNodeNotFoundException(false, array('INFO' => array($field => $locationPrimary)));
}
$result = static::getLinkStatusForMultipleNodes(array($node), $entityPrimary);
return $result[$node['ID']] == self::LSTAT_IS_CONNECTOR || $result[$node['ID']] == self::LSTAT_BELOW_CONNECTOR;
}