• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/userfield/display.php
  • Класс: Bitrix\Crm\UserField\Display
  • Вызов: Display::createByEntityTypeId
static function createByEntityTypeId(int $entityTypeId): Display
{
	$factory = Container::getInstance()->getFactory($entityTypeId);
	if (!$factory)
	{
		// waiting when we will have factories for every entity type
		// really sorry for this:
		$factory = new class extends \Bitrix\Crm\Service\Factory\Contact
		{
			protected $entityTypeIdInternal;

			public function setEntityTypeIdInternal(int $entityTypeId)
			{
				$this->entityTypeIdInternal = $entityTypeId;
			}
			public function getUserFieldEntityId(): string
			{
				return (\CCrmOwnerType::ResolveUserFieldEntityID($this->entityTypeIdInternal));
			}
			public function getEntityTypeId(): int
			{
				return $this->entityTypeIdInternal;
			}
		};
		$factory->setEntityTypeIdInternal($entityTypeId);
	}

	return new self($factory);
}