- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/Service/Display/Field/CrmField.php
- Класс: Bitrix\Crm\Service\Display\Field\CrmField
- Вызов: CrmField::getFormattedValueForMobile
protected function getFormattedValueForMobile($fieldValue, int $itemId, Options $displayOptions): array
{
$result = [];
$linkedEntitiesValues = $this->getLinkedEntitiesValues();
$fieldValue = (is_array($fieldValue) ? $fieldValue : [$fieldValue]);
foreach ($fieldValue as $entityElement)
{
if ($entityElement === null)
{
continue;
}
[$entityTypePrefix, $entityElementId] = $this->explodeEntityElement((string)$entityElement);
if ($entityTypePrefix === null)
{
continue;
}
$entityTypeId = \CCrmOwnerTypeAbbr::ResolveTypeID($entityTypePrefix);
if (!$entityTypeId || !$entityElementId)
{
continue;
}
$entityTypeName = \CCrmOwnerTypeAbbr::ResolveName($entityTypePrefix);
$entityValue = $linkedEntitiesValues[$entityTypeName][$entityElementId];
if (!$entityValue)
{
continue;
}
$title = null;
$imageUrl = null;
$hasReadPermission = $this->hasReadPermissions($entityTypeId, $entityElementId, $entityValue);
if ($hasReadPermission)
{
$title = $this->getEntityTitle($entityTypeId, $entityElementId, $entityValue);
if ($entityTypeId === \CCrmOwnerType::Contact)
{
$logo = $entityValue->get(Contact::FIELD_NAME_PHOTO);
$imageUrl = \CFile::ResizeImageGet(
$logo,
['width' => 200, 'height' => 200],
BX_RESIZE_IMAGE_EXACT,
false,
false,
true
);
$imageUrl = $imageUrl['src'] ?? null;
}
elseif ($entityTypeId === \CCrmOwnerType::Company)
{
$title = $entityValue->getTitle();
$logo = $entityValue->get(Company::FIELD_NAME_LOGO);
$imageUrl = \CFile::ResizeImageGet(
$logo,
['width' => 300, 'height' => 300],
BX_RESIZE_IMAGE_EXACT,
false,
false,
true
);
$imageUrl = $imageUrl['src'] ?? null;
}
}
if (
\CCrmOwnerType::isUseFactoryBasedApproach($entityTypeId)
&& \CCrmOwnerType::isPossibleDynamicTypeId($entityTypeId)
)
{
$entityElementId = DynamicMultipleProvider::prepareId($entityTypeId, $entityElementId);
$entityTypeName = DynamicMultipleProvider::DYNAMIC_MULTIPLE_ID;
}
$result[] = [
'id' => $entityElementId,
'title' => $title,
'type' => mb_strtolower($entityTypeName),
'hidden' => !$hasReadPermission,
'imageUrl' => $imageUrl,
'subtitle' => \CCrmOwnerType::GetDescription($entityTypeId),
];
}
[$entityIds, $providerOptions] = $this->getCrmUserFieldEntityOptions();
return [
'value' => array_column($result, 'id'),
'config' => [
'castType' => 'string',
'selectorTitle' => $this->getTitle(),
'entityList' => $result,
'entityIds' => $entityIds,
'provider' => [
'options' => $providerOptions,
],
],
];
}