- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/counter/monitor/monitorbyentityresponsible.php
- Класс: Bitrix\Crm\Counter\Monitor\MonitorByEntityResponsible
- Вызов: MonitorByEntityResponsible::processEntitiesChanges
protected function processEntitiesChanges(): void
{
$changedEntities = $this->entitiesChangesCollection->significantlyChangedEntitiesForEntityResponsible();
/** @var $changedEntity EntityChange */
foreach ($changedEntities->getValues() as $changedEntity)
{
$entityTypeId = $changedEntity->getIdentifier()->getEntityTypeId();
if ($changedEntity->wasEntityAdded())
{
$factory = Container::getInstance()->getFactory($entityTypeId);
// if entity was added, it only affects the idle counter
if (
$factory && $factory
->getCountersSettings()
->isIdleCounterEnabled()
)
{
$this->resetCounters(
$entityTypeId,
[
EntityCounterType::IDLE,
EntityCounterType::ALL,
],
$changedEntity->getActualAssignedById(),
$changedEntity->getActualCategoryId()
);
}
}
else
{
$affectedResponsibleIds = [];
if ($changedEntity->getNewAssignedById() > 0)
{
$affectedResponsibleIds[] = $changedEntity->getNewAssignedById();
}
if ($changedEntity->isAssignedByChanged() && $changedEntity->getOldAssignedById() > 0)
{
$affectedResponsibleIds[] = $changedEntity->getOldAssignedById();
}
$categoryWasChanged = $changedEntity->isCategoryIdChanged() && !is_null($changedEntity->getOldCategoryId());
foreach ($affectedResponsibleIds as $responsibleId)
{
$this->resetCounters(
$entityTypeId,
EntityCounterType::getAll(true),
$responsibleId,
$changedEntity->getActualCategoryId(),
);
if ($categoryWasChanged)
{
$this->resetCounters(
$entityTypeId,
EntityCounterType::getAll(true),
$responsibleId,
$changedEntity->getOldCategoryId(),
);
}
}
}
}
}