Crm::setDocumentSigningEnabled

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Crm
  4. setDocumentSigningEnabled
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/settings/crm.php
  • Класс: Bitrix\Crm\Settings\Crm
  • Вызов: Crm::setDocumentSigningEnabled
static function setDocumentSigningEnabled(bool $isEnabled): void
{
	if ($isEnabled === (bool)\Bitrix\Main\Config\Option::get(self::OPTION_MODULE, self::DOCUMENT_SIGNING_OPTION_NAME, false))
	{
		return;
	}

	\Bitrix\Main\Config\Option::set(self::OPTION_MODULE, self::DOCUMENT_SIGNING_OPTION_NAME, $isEnabled);

	$relationManager = Container::getInstance()->getRelationManager();
	$relationIdentifier = new RelationIdentifier(\CCrmOwnerType::Deal, \CCrmOwnerType::SmartDocument);

	if ($isEnabled)
	{
		if (!$relationManager->areTypesBound($relationIdentifier))
		{
			try
			{
				$relationManager->bindTypes(
					new Relation(
						$relationIdentifier,
						(new Relation\Settings())
							->setRelationType(Relation\RelationType::CONVERSION)
							->setIsChildrenListEnabled(false)
						,
					)
				);
			}
			catch (SqlQueryException $e)
			{
				if (mb_strpos($e->getMessage(), 'Duplicate entry') === false)
				{
					throw $e;
				}
			}
		}
	}
	else
	{
		$relationManager->unbindTypes($relationIdentifier);
	}
}

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