Scheduler::processEntity

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. Scheduler
  4. processEntity
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/processor/task/scheduler.php
  • Класс: BitrixTasksProcessorTaskScheduler
  • Вызов: Scheduler::processEntity
public function processEntity($id, $data = array(), array $settings = array())
{
	$result = parent::processEntity($id, $data, $settings);

	$id = intval($id);

	// todo: Impact class is TEMPORAL, it should be replaced with (or at least inherited from) BitrixTasksItemTask when ready
	// we set impact on $id regardless of its location in project or being a sub-task
	$taskImpact = new Impact($id, $this->getUserId());

	if(is_array($data))
	{
		$taskImpact->setDataUpdated($data);
	}

	// now we must see if impact on $id affects other tasks...
	$inSubTask = SubTask::isTaskBelong($id, $data);
	$inProject = Project::isTaskBelong($id, $data);

	$this->addImpact($taskImpact);

	if($inSubTask || $inProject)
	{
		if($inSubTask)
		{
			$this->pushQueue($id, $this->getRelationProcessor('S'));
		}
		if($inProject)
		{
			$this->pushQueue($id, $this->getRelationProcessor('P'));
		}

		$times = 0;
		while(count($this->queue) && $times < 10000)
		{
			$times++;
			$next = array_shift($this->queue);

			/** @var BitrixTasksProcessorTaskSchedulerRelationManagerProject|BitrixTasksProcessorTaskSchedulerRelationManagerSubTask $nextProcessor */
			$nextProcessor = $next['PROCESSOR'];

			$metKey = $next['ID'].'-'.$nextProcessor->getCode();
			if ($this->met[$metKey] ?? null)
			{
				continue; // just do not go the same way twice
			}
			$this->met[$metKey] = true;

			/** @var BitrixTasksProcessorTaskSchedulerResultImpact $impact */
			$impact = $this->getImpactById($next['ID']);

			$processorSettings = array();
			if($impact->getId() == $id) // root impact is being processed
			{
				$processorSettings['MODE'] = ($settings['MODE'] ?? null);
			}

			$nextProcessor->processTask($impact, $result, $processorSettings);
		}

		if($times >= 10000)
		{
			$result->addError('ILLEGAL_STRUCTURE.DEPTH', 'Insane tree depth faced');
		}
	}

	$result->setData($this->affected);

	return $result;
}

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