• Модуль: location
  • Путь к файлу: ~/bitrix/modules/location/lib/entity/address/converter/stringtemplateconverter.php
  • Класс: BitrixLocationEntityAddressConverterStringTemplateConverter
  • Вызов: StringTemplateConverter::convert
public function convert(Address $address): string
{
	$result = '';

	$context = $this->createContext();
	$context['template'] = $this->template;
	$context['address'] = $address;

	$context = $this->parseBlocks($context);

	if (!$context['hasError'])
	{
		foreach ($context['info']['blocks'] as $block)
		{
			if ($block['type'] === 'text')
			{
				$result .= $this->unescapeText($block['value']);
			}
			else
			{
				$result .= $block['value'];
			}
		}
	}

	if ($result !== '')
	{
		$result = explode(self::STR_DELIMITER_PLACEHOLDER, $result);
		$result = array_values(
			array_filter($result, function ($part) {
				return ($part !== '');
			})
		);
		if ($this->htmlEncode && !empty($result) && is_array($result))
		{
			array_walk($result, function (&$part) {
				$part = htmlspecialcharsbx($part);
			});
		}

		$result = implode($this->delimiter, $result);
	}

	return $result;
}