Documentation

Component\EntityDetails\FactoryBased

General description

Details for any CRM element are very similar in structure. They consist from elements operating based on similar logic.

During the development of SPA and a new details, it was decided to move general code into a new base class.

This class is abstract, with descendant components for details layout for specific elements/items.

Due this process usually being governed by client's code, the majority of data is concentrated in this class properties.

Majority of methods is also designed to be used inside executeComponent.

Nevertheless, there are cases, you need to externally query the item's details component.

Component name can be retrieved via the router method getItemDetailComponentName.

Below are the methods that can be useful when handling the component externally.

Methods

Method Description Available from version
public function setEntityTypeID(int $id): void
Sets new type for CRM entity $id, handled by the component.
public function getEntityTypeID(): int
Returns current CRM entity type, handled by the component.
public function setEntityID($entityID): void
Sets new item ID, handled by the component.
public function init(): void
Executes initialization - completes internal class properties according to component parameters.
In case of initialization errors, they will be included into error collection.
public function getErrors(): array
Returns array with errors \Bitrix\Main\Error[].
public function getErrorByCode($code): ?Error
Returns error by its $code, if available.
public function getErrorMessages(): array
Returns error message array.
public function initializeEditorAdapter(): void
Initializes the EditorAdapter service.
public function getEditorConfig(): array
Returns parameters for editor component.
public function getInlineEditorEntityConfig(): array
Returns parameters for editor component for item inline editing (for example, in kanban quick create form).
public function getEditorEntityConfig(): array
Returns item config for editor (key ENTITY_CONFIG).
public function prepareFieldInfos(): array
Returns field configuration for editor.

Example of component class


use Bitrix\Crm\Service;

$entityTypeId = 140;

$componentName = Service\Container::getInstance()->getRouter()->getItemDetailComponentName($entityTypeId);

$componentClassName = \CBitrixComponent::includeComponentClass($componentName);
$component = new $componentClassName;
$component->initComponent($componentName);
$component->arParams = [
    'ENTITY_TYPE_ID' => $this->factory->getEntityTypeId(),
    'ENTITY_ID' => 0,
    'categoryId' => $this->getCategoryId(),
];
$component->init();
if ($component->getErrors())
{
    print_r($component->getErrorMessages());
    return;
}

$fieldInfos = $component->prepareFieldInfos();
$entityConfig = $component->getEditorEntityConfig();

Example of component customization can be viewed [link=14018194]here[/link].
© «Bitrix24», 2001-2024