• Модуль: translate
  • Путь к файлу: ~/bitrix/modules/translate/lib/controller/asset/extract.php
  • Класс: BitrixTranslateControllerAssetExtract
  • Вызов: Extract::run
public function run()
{
	// continue previous process
	$progressParams = $this->getProgressParameters();

	$this->archiveFilePath = $progressParams['archiveFilePath'];
	$this->archiveFileType = $progressParams['archiveFileType'];

	$this->totalFileCount = 0;


	$this->tmpFolder = TranslateIODirectory::generateTemporalDirectory('translate');
	if (!$this->tmpFolder->isExists() || !$this->tmpFolder->isDirectory())
	{
		$this->addError(new Error(
			Loc::getMessage('TR_ERROR_CREATE_TEMP_FOLDER', ['#PATH#' => $this->tmpFolder->getPhysicalPath()])
		));
	}
	else
	{
		$this->tmpFolderPath = $this->tmpFolder->getPhysicalPath();
	}

	$this->archiveFile = new TranslateIOArchiver($this->archiveFilePath);
	if (!$this->archiveFile->isExists() || !$this->archiveFile->isFile())
	{
		$this->addError(
			new Error(Loc::getMessage('TR_ERROR_OPEN_FILE', ['#FILE#' => $this->archiveFilePath]))
		);
	}
	elseif ($this->archiveFileType !== '.tar.gz' && $this->archiveFileType !== '.tar')
	{
		$this->addError(new MainError(Loc::getMessage('TR_ERROR_TARFILE_EXTENTION')));
	}

	if (!$this->hasErrors())
	{
		if ($this->archiveFile->extract($this->tmpFolder) !== true)
		{
			if ($this->archiveFile->hasErrors())
			{
				$this->addErrors($this->archiveFile->getErrors());
			}
			else
			{
				$this->addError(
					new MainError(Loc::getMessage('TR_ERROR_ARCHIVE'))
				);
			}
		}
		else
		{
			$this->totalFileCount = $this->archiveFile->getProcessedFileCount();
		}

		// we have to continue process in next action
		$this->processToken = null;

		$this->saveProgressParameters();
	}

	return [
		'STATUS' => TranslateControllerSTATUS_COMPLETED,
		'PROCESSED_ITEMS' => $this->totalFileCount,
		'TOTAL_ITEMS' => $this->totalFileCount,
	];
}