Task::updateBindings

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Task
  4. updateBindings
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/activity/provider/tasks/task.php
  • Класс: Bitrix\Crm\Activity\Provider\Tasks\Task
  • Вызов: Task::updateBindings
public function updateBindings(Bindings $newBindings, Bindings $previousBindings, array $timelineParams): void
{
	$taskId = $timelineParams['TASK_ID'];
	$activity = $this->find($taskId, true);
	$task = TaskObject::getObject($taskId);
	if (is_null($task))
	{
		return;
	}

	if (is_null($activity))
	{
		$timelineParams['ACTIVITY_STATUS'] = Task2ActivityStatus::getStatus((int)$task->getStatus());
		$result = $this->createActivity(
			self::getProviderTypeId(),
			$this->prepareFields($taskId, $newBindings, $timelineParams),
		);
		$activityId = $result->getData()['id'] ?? null;
	}
	else
	{
		$activityId = $activity->getId();
	}

	if (is_null($activityId))
	{
		return;
	}

	if ($newBindings->isEmpty())
	{
		$this->delete($activityId);
	}
	elseif (!$newBindings->isEquals($previousBindings))
	{
		$this->update($activityId, [
			'BINDINGS' => $newBindings->toArray('OWNER_ID', 'OWNER_TYPE_ID'),
		]);

		$ids = $this->getIdsToDelete($previousBindings->getDiff($newBindings), $taskId);
		foreach ($ids as $id)
		{
			TimelineBindingTable::deleteByOwner($id);
		}
	}
}

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