• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/lib/configuration/action/import.php
  • Класс: BitrixRestConfigurationActionImport
  • Вызов: Import::doInitBackground
private function doInitBackground($actionInfo, $data): array
{
	$isEnd = false;
	$next = $actionInfo['step'];
	$structure = new Structure($this->setting->getContext());

	if ($data[self::PROPERTY_FILES] && $data[self::PROPERTY_STRUCTURE][Helper::STRUCTURE_FILES_NAME])
	{
		$chunkList = array_chunk($data[self::PROPERTY_FILES], self::COUNT_ADD_FILES_BY_STEP);
		if (!empty($chunkList[$next]))
		{
			$structure->addFileList(
				$chunkList[$next],
				$data[self::PROPERTY_STRUCTURE][Helper::STRUCTURE_FILES_NAME]
			);
		}
		else
		{
			$isEnd = true;
		}
	}
	else
	{
		$isEnd = true;
	}

	if ($isEnd)
	{
		if (!empty($actionInfo['next']) && (int)$actionInfo['next'] === 0)
		{
			$fileName = Helper::STRUCTURE_SMALL_FILES_NAME . Helper::CONFIGURATION_FILE_EXTENSION;

			foreach ($data[self::PROPERTY_STRUCTURE] as $path)
			{
				if (is_string($path) && mb_strpos($path, $fileName) !== false)
				{
					try
					{
						$content = File::getFileContents($path);
						$structure->unpackSmallFiles($content);
					}
					catch (Exception $e)
					{
					}
					break;
				}
			}
		}
		elseif (!empty($actionInfo['next']) && (int)$actionInfo['next'] > 0)
		{
			//one more step will load small files
			$isEnd = false;
			$next = 0;
		}
	}


	return [
		'next' => $next,
		'finish' => $isEnd,
	];
}