INotifyStorage.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
  4. *
  5. * @author Robin Appelman <robin@icewind.nl>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace OCP\Files\Storage;
  24. use OCP\Files\Notify\INotifyHandler;
  25. /**
  26. * Storage backend that support active notifications
  27. *
  28. * @since 9.1.0
  29. */
  30. interface INotifyStorage {
  31. const NOTIFY_ADDED = 1;
  32. const NOTIFY_REMOVED = 2;
  33. const NOTIFY_MODIFIED = 3;
  34. const NOTIFY_RENAMED = 4;
  35. /**
  36. * Start listening for update notifications
  37. *
  38. * The provided callback will be called for every incoming notification with the following parameters
  39. * - int $type the type of update, one of the INotifyStorage::NOTIFY_* constants
  40. * - string $path the path of the update
  41. * - string $renameTarget the target of the rename operation, only provided for rename updates
  42. *
  43. * Note that this call is blocking and will not exit on it's own, to stop listening for notifications return `false` from the callback
  44. *
  45. * @param string $path
  46. * @param callable $callback
  47. *
  48. * @since 9.1.0
  49. * @deprecated 12.0.0 use INotifyStorage::notify()->listen() instead
  50. */
  51. public function listen($path, callable $callback);
  52. /**
  53. * Start the notification handler for this storage
  54. *
  55. * @param $path
  56. * @return INotifyHandler
  57. *
  58. * @since 12.0.0
  59. */
  60. public function notify($path);
  61. }