Documentation

Converter

Methods


Modern-day frontend web development occupies a significant portion of the code. This code must have a well-crafted structure, subdivided into layers and separated into classes, etc.

Accordingly, frontend side must have a convenient class, allowing to access to CMR element and other entity data.

Javascript-extension prepares this class crm.model.

For the data of this class to be prepared correctly, you need the service Service\Converter.

It is an abstract class; each model type must have its own realization.

The same service is used for generating data in REST methods.


Method Description Available from version
abstract public function toJson($model): array;
Abstract class, converting $model data to json.
public function convertKeysToCamelCase(array $data): array
Recursively converts keys in the $data array to camelCase notation.

Descendants


Service\Converter\OrmObject

The most simple converter type. The method toJson receives EntityObject and converts current object values to json format.


Service\Converter\Item

Coverts CRM data tojson format.

This converter is called automatically in the method Item::jsonSerialize().


Service\Converter\Type

Converts smart process settings data to json. Receives ORM object [link=13967500]\Bitrix\Crm\Model\Dynamic\Type[/link].

Operates in pair with JS-extension crm.type-model.


Service\Converter\Stage

Coverts stage data to json. Receives ORM object \Bitrix\Crm\EO_Status.

Example


use Bitrix\Crm\Service;

$factory = Service\Container::getInstance()->getFactory(\CCrmOwnerType::Quote);
$stages = $factory->getStages();
$converter = Service\Container::getInstance()->getStageConverter();

$json = [];
foreach ($stages as $stage)
{
    $json[] = $converter->toJson($stage);
}
© «Bitrix24», 2001-2024
Up