1
0

IVersionBackend.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Files_Versions\Versions;
  8. use OCP\Files\File;
  9. use OCP\Files\FileInfo;
  10. use OCP\Files\NotFoundException;
  11. use OCP\Files\Storage\IStorage;
  12. use OCP\IUser;
  13. /**
  14. * @since 15.0.0
  15. */
  16. interface IVersionBackend {
  17. /**
  18. * Whether or not this version backend should be used for a storage
  19. *
  20. * If false is returned then the next applicable backend will be used
  21. *
  22. * @param IStorage $storage
  23. * @return bool
  24. * @since 17.0.0
  25. */
  26. public function useBackendForStorage(IStorage $storage): bool;
  27. /**
  28. * Get all versions for a file
  29. *
  30. * @param IUser $user
  31. * @param FileInfo $file
  32. * @return IVersion[]
  33. * @since 15.0.0
  34. */
  35. public function getVersionsForFile(IUser $user, FileInfo $file): array;
  36. /**
  37. * Create a new version for a file
  38. *
  39. * @param IUser $user
  40. * @param FileInfo $file
  41. * @since 15.0.0
  42. */
  43. public function createVersion(IUser $user, FileInfo $file);
  44. /**
  45. * Restore this version
  46. *
  47. * @param IVersion $version
  48. * @since 15.0.0
  49. */
  50. public function rollback(IVersion $version);
  51. /**
  52. * Open the file for reading
  53. *
  54. * @param IVersion $version
  55. * @return resource|false
  56. * @throws NotFoundException
  57. * @since 15.0.0
  58. */
  59. public function read(IVersion $version);
  60. /**
  61. * Get the preview for a specific version of a file
  62. *
  63. * @param IUser $user
  64. * @param FileInfo $sourceFile
  65. * @param int|string $revision
  66. *
  67. * @return File
  68. *
  69. * @since 15.0.0
  70. */
  71. public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File;
  72. }