• Модуль: location
  • Путь к файлу: ~/bitrix/modules/location/lib/entity/address/converter/stringtemplateconverter.php
  • Класс: BitrixLocationEntityAddressConverterStringTemplateConverter
  • Вызов: StringTemplateConverter::parseField
private function parseField(array $context): array
{
	$fieldInfo = [];
	$fieldStartPosition = $context['position'];
	$errors = [];

	// Checking for the presence of a text block
	$context = $this->parseFieldText($context);

	if ($context['hasError'])
	{
		$this->unshiftError($errors, $context['error']['code'], $context['error']['position']);
		$context = $this->clearContextInfoAndError($context);
		// Checking for the presence of a field name
		$context = $this->parseFieldName($context);
	}

	if ($context['hasError'])
	{
		$this->unshiftError($errors, $context['error']['code'], $context['error']['position']);
		$context = $this->clearContextInfoAndError($context);
		// Checking for the presence of a nested group
		$context = $this->parseGroup($context);
		if ($context['hasError'])
		{
			$this->unshiftError($errors, $context['error']['code'], $context['error']['position']);
		}
		else if ($context['info']['position'] > $fieldStartPosition)
		{
			// Group found beyond the expected position
			$this->addContextError($context, self::ERR_PARSE_GROUP_START_POSITION, $fieldStartPosition);
			$this->unshiftError($errors, $context['error']['code'], $context['error']['position']);
		}
	}

	if (!$context['hasError'])
	{
		$fieldInfo = $context['info'];
		$fieldInfo['isFieldListEnd'] = false;
		$context = $this->clearContextInfo($context);

		// Checking for the presence of a field separator
		$context = $this->parseFieldListDelimiter($context);

		if ($context['hasError'])
		{
			$this->unshiftError($errors, $context['error']['code'], $context['error']['position']);
			$context = $this->clearContextInfoAndError($context);
			// Checking for the presence of the end sign of the field list
			$context = $this->parseFieldListEnd($context);
			if ($context['hasError'])
			{
				$this->unshiftError($errors, $context['error']['code'], $context['error']['position']);
			}
			else
			{
				$fieldInfo['isFieldListEnd'] = true;
			}
		}
	}

	if ($context['hasError'])
	{
		$this->unshiftError($errors,  self::ERR_PARSE_GROUP_FIELD, $fieldStartPosition);
		$this->addContextErrors($context, $errors);
	}
	else
	{
		$context['info'] = $fieldInfo;
	}

	return $context;
}