During a single hit, several SPAs data and pipeline uploads may be needed.

This service was created to avoid loading this data several times, as well as for data access convenience.

Life cycle for this service is the following:

  • Instance is retrieved using container.
  • Load method call with parameters to be loaded.
  • Data access is performed using the methods getTypes / getCategories / getStages.
Please note, this class doesn't check access permissions.
Method Description Available from version
public function load(array $params = []): self
Loads SPA data. Array $params can contain two keys:
  • isLoadStages - load stages or not. True by default.
  • isLoadCategories - load pipelines or not. True by default.

When isLoadStages = true, pipelines will be loaded anyway, because all stages cannot be correctly uploaded without a pipeline map.
This method uploads only the data that is missing.
If all requested data was uploaded previously, no additional database queries is performed.
All the rest of this service methods must be called only after the load method was called at least once. Otherwise, throws an exception.
public function getTypes(): array
Returns array with SPAs ORM objects.
public function getCategories
(?int $entityTypeId = null): array
Returns array with SPA pipeline ORM objects.
When the load method didn't request pipelines, throws an exception.
public function getDefaultCategory(int $entityTypeId): 
Returns SPA pipeline ORM object by default for the type with CRM identifier $entityTypeId.
public function getStagesEntityId
(int $entityTypeId, ?int $categoryId = null): 
Returns entity type ID for the table b_crm_status by CRM $entityTypeId of pipeline $categoryId.
When $categoryId is not passed, uses default pipeline for this SPA.
public function getStages
(int $entityTypeId, ?int $categoryId = null): 
Returns array with ORM-objects for Bitrix\Crm\EO_Status SPA stages with CRM $entityTypeId of pipeline $categoryId.
When $categoryId is not passed, uses default pipeline for this smart process.


use Bitrix\Crm\Service;

$dynamicTypesMap = Service\Container::getInstance()->getDynamicTypesMap()->load();

foreach ($dynamicTypesMap->getTypes() as $type)
    echo 'type: ' . htmlspecialcharsbx($type->getTitle()) . PHP_EOL;
    foreach ($dynamicTypesMap->getCategories($type->getEntityTypeId()) as $category)
        echo "\tcategory: " . htmlspecialcharsbx($category->getName()) . PHP_EOL;
        foreach ($dynamicTypesMap->getStages($type->getEntityTypeId(), $category->getId()) as $stage)
            echo "\t\tstage: " . htmlspecialcharsbx($stage->getName()) . PHP_EOL;        

© «Bitrix24», 2001-2023