• Модуль: location
  • Путь к файлу: ~/bitrix/modules/location/lib/entity/address/converter/stringconverter.php
  • Класс: BitrixLocationEntityAddressConverterStringConverter
  • Вызов: StringConverter::convertToStringByField
static function convertToStringByField(Address $address, Format $format, string $contentType, callable $fieldSorter = null): string
{
	$result = '';
	$fields = array_values($format->getFieldCollection()->getItems());

	if($fieldSorter !== null)
	{
		usort($fields, $fieldSorter);
	}

	foreach($fields as $field)
	{
		$fieldValue = $address->getFieldValue($field->getType());

		if($fieldValue === null)
		{
			continue;
		}

		if($contentType === self::CONTENT_TYPE_HTML)
		{
			$fieldValue = htmlspecialcharsbx($fieldValue);
		}

		if($result !== '')
		{
			$result .= $format->getDelimiter();
		}

		$result .= $fieldValue;
	}

	return $result;
}