• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/lib/configuration/structure.php
  • Класс: BitrixRestConfigurationStructure
  • Вызов: Structure::setUnpackFilesFromDisk
public function setUnpackFilesFromDisk($folderId, $storageParams)
{
	$result = false;
	if (Loader::includeModule('disk'))
	{
		try
		{
			$storage = Driver::getInstance()->addStorageIfNotExist(
				$storageParams
			);
			if ($storage)
			{
				$folder = $storage->getChild(
					[
						'=ID' => $folderId
					]
				);
				if ($folder)
				{
					$file = $folder->getChild(
						[
							'=NAME' => Helper::STRUCTURE_FILES_NAME . Helper::CONFIGURATION_FILE_EXTENSION
						]
					);
					if ($file && $file->getFileId() > 0)
					{
						$server = Application::getInstance()->getContext()->getServer();
						$documentRoot = $server->getDocumentRoot();
						$filePath = $documentRoot . CFile::GetPath($file->getFileId());
						if (File::isFileExists($filePath))
						{
							$content = File::getFileContents($filePath);
							$fileList = Json::decode($content);
							if ($fileList)
							{
								$subFolder = $folder->getChild(
									[
										'NAME' => Helper::STRUCTURE_FILES_NAME
									]
								);
								if ($subFolder)
								{
									$fileList = array_column($fileList, null, 'ID');
									$fakeSecurityContext = Driver::getInstance()->getFakeSecurityContext();
									$folderFiles = $subFolder->getChildren(
										$fakeSecurityContext,
										[
											'filter' => [
												'=TYPE' => ObjectTable::TYPE_FILE
											]
										]
									);

									foreach ($folderFiles as $file)
									{
										$id = $file->getOriginalName();
										if (!empty($fileList[$id]))
										{
											$path = $documentRoot . CFile::GetPath(
												$file->getFileId()
											);
											if (File::isFileExists($path))
											{
												$saveFile = $fileList[$id];
												$saveFile['PATH'] = $path;
												$this->setting->set(self::CODE_UNPACK_FILE_PREFIX . $file->getFileId(), $saveFile);
											}
										}
									}

									$result = true;
								}
							}
						}
					}
				}
			}
		}
		catch (Exception $e)
		{
		}
	}
	return $result;
}