• Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/contact.php
  • Класс: BitrixSenderContactTable
  • Вызов: ContactTable::onBeforeUpdate
static function onBeforeUpdate(EntityEvent $event): EntityEventResult
{
	$result = new EntityEventResult;
	$data = $event->getParameters();
	$modify = [];
	if(isset($data['fields']['EMAIL']))
	{
		$modify += array('EMAIL' => RecipientNormalizer::normalizeEmail($data['fields']['EMAIL']));
		$modify += array('CONSENT_STATUS' => 'N');
	}

	if(isset($data['fields']['CODE']))
	{
		$modify += array( 'CONSENT_STATUS' => 'N' );
		$typeId = $data['fields']['TYPE_ID'] ?? null;
		if (!$typeId)
		{
			$row = static::getRowById($data['primary']['ID']);
			$typeId = $row['TYPE_ID'];
		}
		$isValid = RecipientValidator::validate($data['fields']['CODE'], $typeId);
		if (!$isValid)
		{
			$result->addError(new EntityEntityError(Loc::getMessage('SENDER_ENTITY_CONTACT_VALID_CODE')));
		}
		else
		{
			$modify += array('CODE' => RecipientNormalizer::normalize($data['fields']['CODE'], $typeId));
		}
	}
	$result->modifyFields($modify);

	return $result;
}