ChannelRepository::getCommunicationsHoldersForOrder

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. ChannelRepository
  4. getCommunicationsHoldersForOrder
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/messagesender/channel/channelrepository.php
  • Класс: Bitrix\Crm\MessageSender\Channel\ChannelRepository
  • Вызов: ChannelRepository::getCommunicationsHoldersForOrder
static function getCommunicationsHoldersForOrder(ItemIdentifier $source): array
{
	if ($source->getEntityTypeId() !== \CCrmOwnerType::Order)
	{
		throw new ArgumentException('Cant process anything but order in this method');
	}

	$dbRes = \Bitrix\Crm\Order\ContactCompanyCollection::getList([
		'select' => ['ENTITY_ID', 'ENTITY_TYPE_ID'],
		'filter' => [
			'=ORDER_ID' => $source->getEntityId(),
			'IS_PRIMARY' => 'Y'
		]
	]);

	$result = [
		\CCrmOwnerType::Contact => [],
		\CCrmOwnerType::Company => [],
	];

	while ($entity = $dbRes->fetch())
	{
		$entityTypeId = (int)($entity['ENTITY_TYPE_ID'] ?? 0);
		if (!isset($result[$entityTypeId]))
		{
			continue;
		}

		$entityId = (int)($entity['ENTITY_ID'] ?? 0);
		if ($entityId <= 0)
		{
			continue;
		}

		$result[$entityTypeId][$entityId] = $entityId;
	}

	return $result;
}

Добавить комментарий