CCrmEntityHelper::registerRelationEvents

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmEntityHelper
  4. registerRelationEvents
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/entity_helper.php
  • Класс: \CCrmEntityHelper
  • Вызов: CCrmEntityHelper::registerRelationEvents
static function registerRelationEvents(
	ItemIdentifier $itemIdentifier,
	array $params,
	?int $authorId = null
): void
{
	$options = static::extractArrayFromParams($params, 'options');
	$excludeFromRelationRegistration = static::extractArrayFromParams($options, 'EXCLUDE_FROM_RELATION_REGISTRATION');

	$context = null;
	if ($authorId !== null)
	{
		$context = clone Service\Container::getInstance()->getContext();
		$context->setUserId($authorId);
	}

	$relationRegistrar = Service\Container::getInstance()->getRelationRegistrar();

	$relationRegistrar->registerByFieldsChange(
		$itemIdentifier,
		static::extractArrayFromParams($params, 'fieldsInfo'),
		static::extractArrayFromParams($params, 'previousFields'),
		static::extractArrayFromParams($params, 'currentFields'),
		$excludeFromRelationRegistration,
		$context,
	);

	$bindings = static::extractArrayFromParams($params, 'bindings');
	// current bindings are null if they were not changed in this call
	$currentBindings =
		isset($bindings['current']) && is_array($bindings['current'])
			? $bindings['current']
			: null
	;
	if (!empty($bindings) && !is_null($currentBindings))
	{
		$relationRegistrar->registerByBindingsChange(
			$itemIdentifier,
			(int)($bindings['entityTypeId'] ?? 0),
			static::extractArrayFromParams($bindings, 'previous'),
			$currentBindings,
			$excludeFromRelationRegistration,
			$context,
		);
	}
}

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