• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/dispatcher.php
  • Класс: BitrixTasksDOES
  • Вызов: DOES::run
public function run($plan)
{
	$result = new ExecutionResult();

	$this->checkPlan($plan, $result);
	if($result->isSuccess())
	{
		// bind plan operations to the actual routines
		// it could be standard actions, runtime actions or whatever else
		$operations = $this->getOperationsByPlan($plan, $result);

		// todo: this part definitely needs for some refactoring, it is too complicated
		// todo: and especially when we will introduce operation dependency (but which entity this logic should belong to?)

		if($result->isSuccess())
		{
			// execute
			foreach($operations as $code => $op)
			{
				$callResult = $this->wrapOpCall($op);

				$opResult = new Result();
				$opResult->setData($callResult);
				$opResult->getErrors()->load($op->getErrors());

				// store execution result in the plan
				/** @var ToDo $todo */
				$todo = $plan->findOne(array('=CODE' => $code));
				if($todo)
				{
					$todo->setResult($opResult);
				}

				// duplicate errors to the dispatcher, but as warnings
				$errors = $op->getErrors();
				if(!$errors->isEmpty())
				{
					$result->getErrors()->load($op->getErrors()->transform(array('TYPE' => Error::TYPE_WARNING)));
				}
			}
		}
	}

	return $result;
}