• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/integration/bizproc/automation/factory.php
  • Класс: BitrixTasksIntegrationBizprocAutomationFactory
  • Вызов: Factory::createTarget
static function createTarget($documentType, $documentId = null)
{
	$target = null;
	if (DocumentTask::isPersonalTask($documentType))
	{
		$target = new TargetPersonalTask();
	}
	elseif (DocumentTask::isPlanTask($documentType))
	{
		$target = new TargetPlanTask();
	}
	elseif (DocumentTask::isProjectTask($documentType))
	{
		$target = new TargetProjectTask();
	}
	elseif (DocumentTask::isScrumProjectTask($documentType))
	{
		$target = new TargetScrumProjectTask();
	}

	if (!$target)
	{
		throw new NotSupportedException("Document type '{$documentType}' is not supported in current context.");
	}

	$target->setDocumentType(['tasks', DocumentTask::class, $documentType]);

	if ($documentId)
	{
		$target->setDocumentId($documentId);
	}

	return $target;
}