SyncSupport.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace Sabre\CalDAV\Backend;
  3. /**
  4. * WebDAV-sync support for CalDAV backends.
  5. *
  6. * In order for backends to advertise support for WebDAV-sync, this interface
  7. * must be implemented.
  8. *
  9. * Implementing this can result in a significant reduction of bandwidth and CPU
  10. * time.
  11. *
  12. * For this to work, you _must_ return a {http://sabredav.org/ns}sync-token
  13. * property from getCalendarsFromUser.
  14. *
  15. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  16. * @author Evert Pot (http://evertpot.com/)
  17. * @license http://sabre.io/license/ Modified BSD License
  18. */
  19. interface SyncSupport extends BackendInterface {
  20. /**
  21. * The getChanges method returns all the changes that have happened, since
  22. * the specified syncToken in the specified calendar.
  23. *
  24. * This function should return an array, such as the following:
  25. *
  26. * [
  27. * 'syncToken' => 'The current synctoken',
  28. * 'added' => [
  29. * 'new.txt',
  30. * ],
  31. * 'modified' => [
  32. * 'modified.txt',
  33. * ],
  34. * 'deleted' => [
  35. * 'foo.php.bak',
  36. * 'old.txt'
  37. * ]
  38. * );
  39. *
  40. * The returned syncToken property should reflect the *current* syncToken
  41. * of the calendar, as reported in the {http://sabredav.org/ns}sync-token
  42. * property This is * needed here too, to ensure the operation is atomic.
  43. *
  44. * If the $syncToken argument is specified as null, this is an initial
  45. * sync, and all members should be reported.
  46. *
  47. * The modified property is an array of nodenames that have changed since
  48. * the last token.
  49. *
  50. * The deleted property is an array with nodenames, that have been deleted
  51. * from collection.
  52. *
  53. * The $syncLevel argument is basically the 'depth' of the report. If it's
  54. * 1, you only have to report changes that happened only directly in
  55. * immediate descendants. If it's 2, it should also include changes from
  56. * the nodes below the child collections. (grandchildren)
  57. *
  58. * The $limit argument allows a client to specify how many results should
  59. * be returned at most. If the limit is not specified, it should be treated
  60. * as infinite.
  61. *
  62. * If the limit (infinite or not) is higher than you're willing to return,
  63. * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
  64. *
  65. * If the syncToken is expired (due to data cleanup) or unknown, you must
  66. * return null.
  67. *
  68. * The limit is 'suggestive'. You are free to ignore it.
  69. *
  70. * @param string $calendarId
  71. * @param string $syncToken
  72. * @param int $syncLevel
  73. * @param int $limit
  74. * @return array
  75. */
  76. function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null);
  77. }