- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/counter/monitor.php
- Класс: Bitrix\Crm\Counter\Monitor
- Вызов: Monitor::loadActivityResponsibleIds
protected function loadActivityResponsibleIds(array $identifiers): array
{
if (empty($identifiers))
{
return [];
}
$bindQuery = ActivityBindingTable::query()
->registerRuntimeField(
'',
new ReferenceField('A',
ActivityTable::getEntity(),
['=ref.ID' => 'this.ACTIVITY_ID'],
['join_type' => Join::TYPE_INNER])
)
->setSelect(['ACTIVITY_ID', 'OWNER_ID', 'OWNER_TYPE_ID'])
->addSelect('A.RESPONSIBLE_ID', 'RESPONSIBLE_ID');
$orCt = new ConditionTree();
$orCt->logic(ConditionTree::LOGIC_OR);
foreach ($identifiers as $identifier)
{
$ct = new ConditionTree();
$ct->where('OWNER_ID', $identifier->getEntityId());
$ct->where('OWNER_TYPE_ID', $identifier->getEntityTypeId());
$orCt->where($ct);
}
$bindQuery->where($orCt);
$bindings = $bindQuery->fetchAll();
if (empty($bindings))
{
return [];
}
$result = [];
foreach ($bindings as $bind)
{
$key = (new ItemIdentifier($bind['OWNER_TYPE_ID'], $bind['OWNER_ID']))->getHash();
if (!isset($result[$key]))
{
$result[$key] = [];
}
$result[$key][] = (int) $bind['RESPONSIBLE_ID'];
}
return array_map(fn($resp) => array_unique($resp), $result);
}