• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/recycling/leadcontroller.php
  • Класс: Bitrix\Crm\Recycling\LeadController
  • Вызов: LeadController::prepareEntityData
public function prepareEntityData($entityID, array $params = array())
{
	$fields = isset($params['FIELDS']) && is_array($params['FIELDS']) ? $params['FIELDS'] : null;
	if(empty($fields))
	{
		$fields = $this->getEntityFields($entityID);
	}

	if(empty($fields))
	{
		throw new Main\ObjectNotFoundException("Could not find entity: #{$entityID}.");
	}

	$slots = [
		'FIELDS' => array_intersect_key($fields, array_flip(self::getFieldNames())),
	];

	$companyID = isset($fields['COMPANY_ID']) ? (int)$fields['COMPANY_ID'] : 0;
	if($companyID > 0)
	{
		$slots['COMPANY_ID'] = $companyID;
	}

	$contactIDs = Crm\Binding\LeadContactTable::getLeadContactIDs($entityID);
	if(!empty($contactIDs))
	{
		$slots['CONTACT_IDS'] = $contactIDs;
	}

	$childContactIDs = Crm\Entity\Lead::getChildEntityIDs($entityID, \CCrmOwnerType::Contact);
	if(!empty($childContactIDs))
	{
		$slots['CHILD_CONTACT_IDS'] = $childContactIDs;
	}

	$childCompanyIDs = Crm\Entity\Lead::getChildEntityIDs($entityID, \CCrmOwnerType::Company);
	if(!empty($childCompanyIDs))
	{
		$slots['CHILD_COMPANY_IDS'] = $childCompanyIDs;
	}

	$childDealIDs = Crm\Entity\Lead::getChildEntityIDs($entityID, \CCrmOwnerType::Deal);
	if(!empty($childDealIDs))
	{
		$slots['CHILD_DEAL_IDS'] = $childDealIDs;
	}

	$childQuoteIds = Crm\Entity\Lead::getChildEntityIDs($entityID, \CCrmOwnerType::Quote);
	if(!empty($childQuoteIds))
	{
		$slots['CHILD_QUOTE_IDS'] = $childQuoteIds;
	}

	$slots = array_merge($slots, $this->prepareActivityData($entityID, $params));

	return array(
		'TITLE' => \CCrmOwnerType::GetCaption(
			\CCrmOwnerType::Lead,
			$entityID,
			false,
			array('FIELDS' => $fields)
		),
		'SLOTS' => $slots
	);
}