IExportDestination.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\UserMigration;
  8. use OCP\Files\Folder;
  9. /**
  10. * @since 24.0.0
  11. */
  12. interface IExportDestination {
  13. /**
  14. * Adds a file to the export
  15. *
  16. * @param string $path Full path to the file in the export archive. Parent directories will be created if needed.
  17. * @param string $content The full content of the file.
  18. * @throws UserMigrationException
  19. *
  20. * @since 24.0.0
  21. */
  22. public function addFileContents(string $path, string $content): void;
  23. /**
  24. * Adds a file to the export as a stream
  25. *
  26. * @param string $path Full path to the file in the export archive. Parent directories will be created if needed.
  27. * @param resource $stream A stream resource to read from to get the file content.
  28. * @throws UserMigrationException
  29. *
  30. * @since 24.0.0
  31. */
  32. public function addFileAsStream(string $path, $stream): void;
  33. /**
  34. * Copy a folder to the export
  35. *
  36. * @param Folder $folder folder to copy to the export archive.
  37. * @param string $destinationPath Full path to the folder in the export archive. Parent directories will be created if needed.
  38. * @param ?callable(\OCP\Files\Node):bool $nodeFilter Callback to filter nodes to copy
  39. * @throws UserMigrationException
  40. *
  41. * @since 24.0.0
  42. */
  43. public function copyFolder(Folder $folder, string $destinationPath, ?callable $nodeFilter = null): void;
  44. /**
  45. * @param array<string,int> $versions Migrators and their versions.
  46. * @throws UserMigrationException
  47. *
  48. * @since 24.0.0
  49. */
  50. public function setMigratorVersions(array $versions): void;
  51. /**
  52. * Called after export is complete
  53. *
  54. * @throws UserMigrationException
  55. *
  56. * @since 24.0.0
  57. */
  58. public function close(): void;
  59. }