Task::copyReplica

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. Task
  4. copyReplica
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/copy/implement/task.php
  • Класс: BitrixTasksCopyImplementTask
  • Вызов: Task::copyReplica
private function copyReplica(Container $parentContainer, int $taskId, int $copiedTaskId)
{
	if (!$this->templateCopier)
	{
		return new Result();
	}

	$parentDictionary = $parentContainer->getDictionary();
	if ($parentDictionary->get('REPLICATE') !== 'Y')
	{
		return new Result();
	}

	$containerCollection = new ContainerCollection();

	$dictionary = new Dictionary();
	$dictionary->set('TASK_ID', $copiedTaskId);
	if ($this->targetGroupId)
	{
		$dictionary->set('GROUP_ID', $this->targetGroupId);
	}

	$queryObject = TemplateTable::getList([
		'select' => ['ID'],
		'filter' => [
			'TASK_ID' => $taskId,
			'REPLICATE' => 'Y',
		],
	]);
	while ($templateData = $queryObject->fetch())
	{
		$container = new Container($templateData['ID']);

		$container->setDictionary($dictionary);

		$containerCollection[] = $container;
	}

	if (!$containerCollection->isEmpty())
	{
		return $this->templateCopier->copy($containerCollection);
	}

	return new Result();
}

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