• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/admin/locationhelper.php
  • Класс: BitrixSaleLocationAdminLocationHelper
  • Вызов: LocationHelper::validateUpdateRequest
static function validateUpdateRequest($data)
{
	$errors = parent::validateUpdateRequest($data);

	// if type is set in data and not empty, it must exist
	$typeError = false;
	$typeId = (int)($data['TYPE_ID'] ?? 0);
	if ($typeId > 0)
	{
		$type = LocationTypeTable::getRow([
			'select' => [
				'ID'
			],
			'filter' => [
				'=ID' => $typeId,
			],
		]);

		if (!$type)
		{
			$typeError = true;
		}
	}
	else
	{
		$typeError = true;
	}

	if ($typeError)
	{
		$errors[] = Loc::getMessage('SALE_LOCATION_ADMIN_LOCATION_HELPER_ENTITY_TYPE_ID_UNKNOWN_ERROR');
	}

	// formally check service ids in EXTERNAL parameter
	if (!empty($data['EXTERNAL']) && is_array($data['EXTERNAL']))
	{
		$services = self::getExternalServicesList();

		foreach ($data['EXTERNAL'] as $external)
		{
			if (!isset($services[$external['SERVICE_ID']]))
			{
				$errors[] = Loc::getMessage('SALE_LOCATION_ADMIN_LOCATION_HELPER_ENTITY_UNKNOWN_EXTERNAL_SERVICE_ID_ERROR');
				break;
			}
		}
	}

	if (!empty($data['NAME']) && is_array($data['NAME']))
	{
		$hasValidName = false;

		foreach($data['NAME'] as $fields)
		{
			if (!empty($fields['NAME']))
			{
				$hasValidName = true;
				break;
			}
		}

		if (!$hasValidName)
		{
			$errors[] = Loc::getMessage('SALE_LOCATION_ADMIN_LOCATION_HELPER_ENTITY_NAME_EMPTY_ERROR');
		}
	}

	return $errors;
}