• Модуль: crmmobile
  • Путь к файлу: ~/bitrix/modules/crmmobile/lib/Controller/Stage.php
  • Класс: BitrixCrmMobileControllerStage
  • Вызов: Stage::createAction
public function createAction(Factory $factory, int $categoryId, array $fields): ?DtoStage
{
	$entityId = $factory->getStagesEntityId($categoryId);
	$status = new CCrmStatus($entityId);

	if (!Container::getInstance()->getUserPermissions()->canWriteConfig())
	{
		$this->addError(ErrorCode::getAccessDeniedError());
		return null;
	}

	$id = $status->Add([
		'NAME' => $fields['name'],
		'SORT' => $fields['sort'],
		'SEMANTICS' => $fields['semantics'],
		'COLOR' => $fields['color'],
	]);

	if (!$id)
	{
		$this->addError(new Error($status->GetLastError()));
		return null;
	}

	$this->resortStagesAndSave($factory, $categoryId);

	$stage = $status->GetStatusById($id);

	return new DtoStage([
		'id' => $stage['ID'],
		'name' => $stage['NAME'],
		'sort' => $stage['SORT'],
		'color' => $stage['COLOR'],
		'semantics' => $stage['SEMANTICS'],
		'statusId' => $stage['STATUS_ID'],
	]);
}