• Модуль: location
  • Путь к файлу: ~/bitrix/modules/location/lib/entity/format/fieldcollection.php
  • Класс: Bitrix\Location\Entity\Format\FieldCollection
  • Вызов: FieldCollection::addItem
public function addItem($field): int
{
	if(!($field instanceof Field))
	{
		throw new ArgumentTypeException('field must be the instance of Field');
	}

	$result = parent::addItem($field);

	/*
	 * Sort fields due to sort
	 * @todo: what about performance?
	 */
	usort(
		$this->items,
		function (Field $a, Field $b)
		{
			if ($a->getSort() === $b->getSort())
			{
				return 0;
			}

			return ($a->getSort() < $b->getSort()) ? -1 : 1;
		}
	);

	return $result;
}