ISyncCollection.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\DAV\Sync;
  4. use Sabre\DAV;
  5. /**
  6. * If a class extends ISyncCollection, it supports WebDAV-sync.
  7. *
  8. * You are responsible for maintaining a changelist for this collection. This
  9. * means that if any child nodes in this collection was created, modified or
  10. * deleted in any way, you should maintain an updated changelist.
  11. *
  12. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  13. * @author Evert Pot (http://evertpot.com/)
  14. * @license http://sabre.io/license/ Modified BSD License
  15. */
  16. interface ISyncCollection extends DAV\ICollection
  17. {
  18. /**
  19. * This method returns the current sync-token for this collection.
  20. * This can be any string.
  21. *
  22. * If null is returned from this function, the plugin assumes there's no
  23. * sync information available.
  24. *
  25. * @return string|null
  26. */
  27. public function getSyncToken();
  28. /**
  29. * The getChanges method returns all the changes that have happened, since
  30. * the specified syncToken and the current collection.
  31. *
  32. * This function should return an array, such as the following:
  33. *
  34. * [
  35. * 'syncToken' => 'The current synctoken',
  36. * 'added' => [
  37. * 'new.txt',
  38. * ],
  39. * 'modified' => [
  40. * 'modified.txt',
  41. * ],
  42. * 'deleted' => array(
  43. * 'foo.php.bak',
  44. * 'old.txt'
  45. * )
  46. * ];
  47. *
  48. * The syncToken property should reflect the *current* syncToken of the
  49. * collection, as reported getSyncToken(). This is needed here too, to
  50. * ensure the operation is atomic.
  51. *
  52. * If the syncToken is specified as null, this is an initial sync, and all
  53. * members should be reported.
  54. *
  55. * The modified property is an array of nodenames that have changed since
  56. * the last token.
  57. *
  58. * The deleted property is an array with nodenames, that have been deleted
  59. * from collection.
  60. *
  61. * The second argument is basically the 'depth' of the report. If it's 1,
  62. * you only have to report changes that happened only directly in immediate
  63. * descendants. If it's 2, it should also include changes from the nodes
  64. * below the child collections. (grandchildren)
  65. *
  66. * The third (optional) argument allows a client to specify how many
  67. * results should be returned at most. If the limit is not specified, it
  68. * should be treated as infinite.
  69. *
  70. * If the limit (infinite or not) is higher than you're willing to return,
  71. * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
  72. *
  73. * If the syncToken is expired (due to data cleanup) or unknown, you must
  74. * return null.
  75. *
  76. * The limit is 'suggestive'. You are free to ignore it.
  77. *
  78. * @param string $syncToken
  79. * @param int $syncLevel
  80. * @param int $limit
  81. *
  82. * @return array|null
  83. */
  84. public function getChanges($syncToken, $syncLevel, $limit = null);
  85. }