• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/controller/category.php
  • Класс: Bitrix\Crm\Controller\Category
  • Вызов: Category::addAction
public function addAction(int $entityTypeId, array $fields): ?array
{
	$factory = $this->getFactory($entityTypeId);
	if (!$factory)
	{
		return null;
	}

	if ($fields['isSystem'] === 'Y')
	{
		$this->addError(
			new Error(
				Loc::getMessage('CRM_TYPE_CATEGORY_ADD_ERROR_SYSTEM'),
				ErrorCode::ADDING_DISABLED
			)
		);

		return null;
	}

	$category = $factory->createCategory();
	if (!$this->userPermissions->canAddCategory($category))
	{
		$this->addError(ErrorCode::getAccessDeniedError());
		return null;
	}

	return $this->updateCategory($factory, $category, $fields);
}