- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/timeline/leadcontroller.php
- Класс: Bitrix\Crm\Timeline\LeadController
- Вызов: LeadController::onRestore
public function onRestore($ownerID, array $params)
{
if(!is_int($ownerID))
{
$ownerID = (int)$ownerID;
}
if($ownerID <= 0)
{
throw new Main\ArgumentException('Owner ID must be greater than zero.', 'ownerID');
}
$fields = isset($params['FIELDS']) && is_array($params['FIELDS']) ? $params['FIELDS'] : null;
if (is_array($fields))
{
$fieldsMap = $params['FIELDS_MAP'] ?? null;
if (is_array($fieldsMap))
{
$fields = EntityFieldsHelper::replaceFieldNamesByMap($fields, $fieldsMap);
}
}
else
{
$fields = self::getEntity($ownerID);
}
if(!is_array($fields))
{
return;
}
$historyEntryID = RestorationEntry::create(
array(
'ENTITY_TYPE_ID' => \CCrmOwnerType::Lead,
'ENTITY_ID' => $ownerID,
'AUTHOR_ID' => self::resolveCreatorID($fields),
'SETTINGS' => array(),
'BINDINGS' => array(
array(
'ENTITY_TYPE_ID' => \CCrmOwnerType::Lead,
'ENTITY_ID' => $ownerID
)
)
)
);
$enableHistoryPush = $historyEntryID > 0;
if($enableHistoryPush && Main\Loader::includeModule('pull'))
{
$pushParams = array('ID' => $ownerID);
if($enableHistoryPush)
{
$historyFields = TimelineEntry::getByID($historyEntryID);
if(is_array($historyFields))
{
$pushParams['HISTORY_ITEM'] = $this->prepareHistoryDataModel(
$historyFields,
array('ENABLE_USER_INFO' => true)
);
}
}
$tag = $pushParams['TAG'] = TimelineEntry::prepareEntityPushTag(\CCrmOwnerType::Lead, 0);
\CPullWatch::AddToStack(
$tag,
array(
'module_id' => 'crm',
'command' => self::RESTORE_EVENT_NAME,
'params' => $pushParams,
)
);
}
}