Your IP : 216.73.216.86


Current Path : /var/www/homesaver/www/bitrix/modules/sender/lib/service/
Upload File :
Current File : /var/www/homesaver/www/bitrix/modules/sender/lib/service/contactupdateservice.php

<?php

namespace Bitrix\Sender\Service;

use Bitrix\Sender\ContactTable;
use Bitrix\Sender\Internals\Dto\UpdateContactDtoCollection;
use Bitrix\Sender\Internals\SqlBatch;

final class ContactUpdateService
{
	/**
	 * Update contacts from DTO collection
	 *
	 * @param UpdateContactDtoCollection $collection DTOs collection
	 *
	 * @return void
	 */
	public function updateByCollection(UpdateContactDtoCollection $collection): void
	{
		$onDuplicateUpdateFields = [
			'NAME',
			'BLACKLISTED',
			'DATE_UPDATE',
		];
		foreach (SqlBatch::divide($collection->toArray()) as $list)
		{
			SqlBatch::insert(
				ContactTable::getTableName(),
				$list,
				$onDuplicateUpdateFields,
				ContactTable::getConflictFields(),
			);
		}
	}
}