IEventMerger.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
  4. *
  5. * @license GNU AGPL version 3 or any later version
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as
  9. * published by the Free Software Foundation, either version 3 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. namespace OCP\Activity;
  22. /**
  23. * Interface EventMerger
  24. *
  25. * @package OCP\Activity
  26. * @since 11.0
  27. */
  28. interface IEventMerger {
  29. /**
  30. * Combines two events when possible to have grouping:
  31. *
  32. * Example1: Two events with subject '{user} created {file}' and
  33. * $mergeParameter file with different file and same user will be merged
  34. * to '{user} created {file1} and {file2}' and the childEvent on the return
  35. * will be set, if the events have been merged.
  36. *
  37. * Example2: Two events with subject '{user} created {file}' and
  38. * $mergeParameter file with same file and same user will be merged to
  39. * '{user} created {file1}' and the childEvent on the return will be set, if
  40. * the events have been merged.
  41. *
  42. * The following requirements have to be met, in order to be merged:
  43. * - Both events need to have the same `getApp()`
  44. * - Both events must not have a message `getMessage()`
  45. * - Both events need to have the same subject `getSubject()`
  46. * - Both events need to have the same object type `getObjectType()`
  47. * - The time difference between both events must not be bigger then 3 hours
  48. * - Only up to 5 events can be merged.
  49. * - All parameters apart from such starting with $mergeParameter must be
  50. * the same for both events.
  51. *
  52. * @param string $mergeParameter
  53. * @param IEvent $event
  54. * @param IEvent|null $previousEvent
  55. * @return IEvent
  56. * @since 11.0
  57. */
  58. public function mergeEvents($mergeParameter, IEvent $event, IEvent $previousEvent = null);
  59. }