IsMyCompany::processLogic

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. IsMyCompany
  4. processLogic
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Field/IsMyCompany.php
  • Класс: Bitrix\Crm\Field\IsMyCompany
  • Вызов: IsMyCompany::processLogic
protected function processLogic(Item $item, Context $context = null): Result
{
	$result = new Result();

	if (!$item->isCategoriesSupported())
	{
		return $result;
	}

	$factory = Container::getInstance()->getFactory($item->getEntityTypeId());
	if (!$factory)
	{
		return $result->addError($this->getFactoryNotFoundError($item->getEntityTypeId()));
	}

	$defaultCategory = $factory->createDefaultCategoryIfNotExist();

	if ($item->get($this->getName()) && $item->getCategoryId() !== $defaultCategory->getId())
	{
		return $result->addError(
			new Error(
				Loc::getMessage('CRM_ERROR_FIELD_MY_COMPANY_IN_CUSTOM_CATEGORY')
			)
		);
	}

	return $result;
}

Добавить комментарий