IManager.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  6. * SPDX-License-Identifier: AGPL-3.0-only
  7. */
  8. namespace OCP\Activity;
  9. use OCP\Activity\Exceptions\FilterNotFoundException;
  10. use OCP\Activity\Exceptions\IncompleteActivityException;
  11. use OCP\Activity\Exceptions\SettingNotFoundException;
  12. /**
  13. * Interface IManager
  14. *
  15. * @since 6.0.0
  16. */
  17. interface IManager {
  18. /**
  19. * Generates a new IEvent object
  20. *
  21. * Make sure to call at least the following methods before sending it to the
  22. * app with via the publish() method:
  23. * - setApp()
  24. * - setType()
  25. * - setAffectedUser()
  26. * - setSubject()
  27. * - setObject()
  28. *
  29. * @return IEvent
  30. * @since 8.2.0
  31. */
  32. public function generateEvent(): IEvent;
  33. /**
  34. * Publish an event to the activity consumers
  35. *
  36. * Make sure to call at least the following methods before sending an Event:
  37. * - setApp()
  38. * - setType()
  39. * - setAffectedUser()
  40. * - setSubject()
  41. * - setObject()
  42. *
  43. * @param IEvent $event
  44. * @throws IncompleteActivityException if required values have not been set
  45. * @since 8.2.0
  46. * @since 30.0.0 throws {@see IncompleteActivityException} instead of \BadMethodCallException
  47. */
  48. public function publish(IEvent $event): void;
  49. /**
  50. * In order to improve lazy loading a closure can be registered which will be called in case
  51. * activity consumers are actually requested
  52. *
  53. * $callable has to return an instance of \OCP\Activity\IConsumer
  54. *
  55. * @param \Closure $callable
  56. * @since 6.0.0
  57. */
  58. public function registerConsumer(\Closure $callable): void;
  59. /**
  60. * @param string $filter Class must implement OCA\Activity\IFilter
  61. * @since 11.0.0
  62. */
  63. public function registerFilter(string $filter): void;
  64. /**
  65. * @return IFilter[]
  66. * @since 11.0.0
  67. */
  68. public function getFilters(): array;
  69. /**
  70. * @param string $id
  71. * @return IFilter
  72. * @throws FilterNotFoundException when the filter was not found
  73. * @since 11.0.0
  74. * @since 30.0.0 throws {@see FilterNotFoundException} instead of \InvalidArgumentException
  75. */
  76. public function getFilterById(string $id): IFilter;
  77. /**
  78. * @param string $setting Class must implement OCA\Activity\ISetting
  79. * @since 11.0.0
  80. */
  81. public function registerSetting(string $setting): void;
  82. /**
  83. * @return ActivitySettings[]
  84. * @since 11.0.0
  85. */
  86. public function getSettings(): array;
  87. /**
  88. * @param string $provider Class must implement OCA\Activity\IProvider
  89. * @since 11.0.0
  90. */
  91. public function registerProvider(string $provider): void;
  92. /**
  93. * @return IProvider[]
  94. * @since 11.0.0
  95. */
  96. public function getProviders(): array;
  97. /**
  98. * @param string $id
  99. * @return ActivitySettings
  100. * @throws SettingNotFoundException when the setting was not found
  101. * @since 11.0.0
  102. * @since 30.0.0 throws {@see SettingNotFoundException} instead of \InvalidArgumentException
  103. */
  104. public function getSettingById(string $id): ActivitySettings;
  105. /**
  106. * @param string $type
  107. * @param int $id
  108. * @since 8.2.0
  109. */
  110. public function setFormattingObject(string $type, int $id): void;
  111. /**
  112. * @return bool
  113. * @since 8.2.0
  114. */
  115. public function isFormattingFilteredObject(): bool;
  116. /**
  117. * @param bool $status Set to true, when parsing events should not use SVG icons
  118. * @since 12.0.1
  119. */
  120. public function setRequirePNG(bool $status): void;
  121. /**
  122. * @return bool
  123. * @since 12.0.1
  124. */
  125. public function getRequirePNG(): bool;
  126. /**
  127. * Set the user we need to use
  128. *
  129. * @param string|null $currentUserId
  130. * @since 9.0.1
  131. */
  132. public function setCurrentUserId(?string $currentUserId = null): void;
  133. /**
  134. * Get the user we need to use
  135. *
  136. * Either the user is logged in, or we try to get it from the token
  137. *
  138. * @return string
  139. * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
  140. * @since 8.1.0
  141. */
  142. public function getCurrentUserId(): string;
  143. }