CCrmEntityHelper::prepareOperationByOptions

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmEntityHelper
  4. prepareOperationByOptions
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/entity_helper.php
  • Класс: \CCrmEntityHelper
  • Вызов: CCrmEntityHelper::prepareOperationByOptions
static function prepareOperationByOptions(
	\Bitrix\Crm\Service\Operation $operation,
	array $options,
	bool $checkPermissions
): void
{
	$context = clone \Bitrix\Crm\Service\Container::getInstance()->getContext();

	if (isset($options['ITEM_OPTIONS']))
	{
		$context->setItemOptions($options['ITEM_OPTIONS']);
	}
	if (isset($options['CURRENT_USER']) && (int)$options['CURRENT_USER'] > 0)
	{
		$context->setUserId((int)$options['CURRENT_USER']);
	}
	if (isset($options['eventId']))
	{
		$context->setEventId($options['eventId']);
	}
	$operation->setContext($context);

	if (!$checkPermissions)
	{
		$operation->disableCheckAccess();
	}

	$disableUserFieldsCheck = $options['DISABLE_USER_FIELD_CHECK'] ?? false;
	if ($disableUserFieldsCheck === true)
	{
		$operation->disableCheckFields();
	}

	$disableRequiredUserFieldsCheck = $options['DISABLE_REQUIRED_USER_FIELD_CHECK'] ?? false;
	if ($disableRequiredUserFieldsCheck === true)
	{
		$operation->disableCheckRequiredUserFields();
	}

	$excludeFromRelationRegistration =
		isset($options['EXCLUDE_FROM_RELATION_REGISTRATION']) && is_array($options['EXCLUDE_FROM_RELATION_REGISTRATION'])
			? $options['EXCLUDE_FROM_RELATION_REGISTRATION']
			: []
	;
	if (!empty($excludeFromRelationRegistration))
	{
		$operation->excludeItemsFromTimelineRelationEventsRegistration($excludeFromRelationRegistration);
	}

	$operation->disableCheckLimits();

	$isCompareEnabled = (bool)($options['IS_COMPARE_ENABLED'] ?? true);
	if ($isCompareEnabled === false)
	{
		$operation->disableSaveToHistory();
	}

	$disableTimeline = isset($options['DISABLE_TIMELINE_CREATION']) ? ($options['DISABLE_TIMELINE_CREATION'] === 'Y') : false;
	if ($disableTimeline === true)
	{
		$operation->disableSaveToTimeline();
	}

	$enableDeferredMode = (bool)($options['ENABLE_DEFERRED_MODE'] ?? true);
	if ($enableDeferredMode)
	{
		$operation->enableDeferredCleaning();
	}
	else
	{
		$operation->disableDeferredCleaning();
	}

	$enableDupIndexInvalidation = (bool)($options['ENABLE_DUP_INDEX_INVALIDATION'] ?? true);
	if ($enableDupIndexInvalidation)
	{
		$operation->enableDuplicatesIndexInvalidation();
	}
	else
	{
		$operation->disableDuplicatesIndexInvalidation();
	}

	if (isset($options['ENABLE_ACTIVITY_COMPLETION']) && is_bool($options['ENABLE_ACTIVITY_COMPLETION']))
	{
		if ($options['ENABLE_ACTIVITY_COMPLETION'])
		{
			$operation->enableActivitiesAutocompletion();
		}
		else
		{
			$operation->disableActivitiesAutocompletion();
		}
	}

	$processBizProc = (bool)($options['PROCESS_BIZPROC'] ?? true);
	if ($processBizProc)
	{
		$operation->enableBizProc();
	}
	else
	{
		$operation->disableBizProc();
	}
}

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