1
0

IVersionBackend.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCA\Files_Versions\Versions;
  26. use OCP\Files\File;
  27. use OCP\Files\FileInfo;
  28. use OCP\Files\NotFoundException;
  29. use OCP\Files\Storage\IStorage;
  30. use OCP\IUser;
  31. /**
  32. * @since 15.0.0
  33. */
  34. interface IVersionBackend {
  35. /**
  36. * Whether or not this version backend should be used for a storage
  37. *
  38. * If false is returned then the next applicable backend will be used
  39. *
  40. * @param IStorage $storage
  41. * @return bool
  42. * @since 17.0.0
  43. */
  44. public function useBackendForStorage(IStorage $storage): bool;
  45. /**
  46. * Get all versions for a file
  47. *
  48. * @param IUser $user
  49. * @param FileInfo $file
  50. * @return IVersion[]
  51. * @since 15.0.0
  52. */
  53. public function getVersionsForFile(IUser $user, FileInfo $file): array;
  54. /**
  55. * Create a new version for a file
  56. *
  57. * @param IUser $user
  58. * @param FileInfo $file
  59. * @since 15.0.0
  60. */
  61. public function createVersion(IUser $user, FileInfo $file);
  62. /**
  63. * Restore this version
  64. *
  65. * @param IVersion $version
  66. * @since 15.0.0
  67. */
  68. public function rollback(IVersion $version);
  69. /**
  70. * Open the file for reading
  71. *
  72. * @param IVersion $version
  73. * @return resource
  74. * @throws NotFoundException
  75. * @since 15.0.0
  76. */
  77. public function read(IVersion $version);
  78. /**
  79. * Get the preview for a specific version of a file
  80. *
  81. * @param IUser $user
  82. * @param FileInfo $sourceFile
  83. * @param int|string $revision
  84. *
  85. * @return File
  86. *
  87. * @since 15.0.0
  88. */
  89. public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File;
  90. }