• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/entityproperty.php
  • Класс: BitrixSaleEntityProperty
  • Вызов: EntityProperty::normalizeValue
public function normalizeValue($value)
{
	if ($this->fields['TYPE'] === 'FILE')
	{
		return InputFile::loadInfo($value);
	}
	elseif ($this->fields['TYPE'] === 'ADDRESS' && MainLoader::includeModule('location'))
	{
		if (is_array($value))
		{
			/**
			 * Already normalized
			 */
			return $value;
		}
		elseif (is_numeric($value))
		{
			/**
			 * DB value
			 */
			$address = Address::load((int)$value);

			$value = ($address instanceof Address) ? $address->toArray() : null;
		}
		elseif (is_string($value) && !empty($value))
		{
			/**
			 * JSON most likely
			 */

			try
			{
				$result = MainWebJson::decode(
					MainTextEncoding::convertEncoding(
						$value,
						SITE_CHARSET,
						'UTF-8'
					)
				);
			}
			catch (Exception $exception)
			{
				$result = (new Address(LANGUAGE_ID))
					->setFieldValue(AddressFieldType::ADDRESS_LINE_2, $value)
					->toArray();
			}

			return $result;
		}
	}
	elseif ($this->fields['TYPE'] === "STRING")
	{
		if ($this->fields['IS_EMAIL'] === "Y" && !empty($value))
		{
			$value = trim((string)$value);
		}

		if (InputStringInput::isMultiple($value))
		{
			foreach ($value as $key => $data)
			{
				if (InputStringInput::isDeletedSingle($data))
				{
					unset($value[$key]);
				}
			}
		}

		return $value;
	}

	return $value;
}