• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/order/contactcompanycollection.php
  • Класс: Bitrix\Crm\Order\ContactCompanyCollection
  • Вызов: ContactCompanyCollection::addItem
public function addItem(CollectableEntity $item)
{
	if (!($item instanceof ContactCompanyEntity))
	{
		throw new Main\NotSupportedException();
	}

	if ($item instanceof Company
		&& $this->getCompanies()->count() === 1)
	{
		throw new Main\SystemException('Multiple companies are not supported');
	}

	if ($this->isItemExists($item))
	{
		throw new Main\SystemException('Addable item has already existed');
	}

	if ($item->isPrimary()
		&& $this->isPrimaryItemExists($item::getEntityType())
	)
	{
		throw new Main\SystemException('Primary '.ToLower($item::getEntityTypeName()).' has already existed');
	}

	return parent::addItem($item);
}