SyncSupport.php 2.8 KB

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