• Модуль: rpa
  • Путь к файлу: ~/bitrix/modules/rpa/lib/controller/stage.php
  • Класс: BitrixRpaControllerStage
  • Вызов: Stage::saveAllAction
public function saveAllAction(BitrixRpaModelType $type, array $stages): array
{
	$currentStages = $type->getStages();
	$models = [];
	foreach($stages as $fields)
	{
		$fields['id'] = (int)$fields['id'];
		if($fields['id'] > 0)
		{
			$stage = $currentStages->getByPrimary($fields['id']);
			if($stage)
			{
				$this->updateAction($stage, $fields);
				$models[] = $stage;
			}
		}
		else
		{
			$stage = new BitrixRpaModelStage();
			$this->updateAction($stage, $fields);
			$models[] = $stage;
		}
	}

	$result = [
		'stages' => [],
	];

	foreach($currentStages as $currentStage)
	{
		if(!in_array($currentStage, $models))
		{
			$this->deleteAction($currentStage);
		}
	}

	foreach($models as $stage)
	{
		$result['stages'][$stage->getId()] = $this->prepareData($stage, false);
	}

	return $result;
}