IManager.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Robin Appelman <robin@icewind.nl>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCP\Activity;
  28. use OCP\Activity\Exceptions\FilterNotFoundException;
  29. use OCP\Activity\Exceptions\IncompleteActivityException;
  30. use OCP\Activity\Exceptions\SettingNotFoundException;
  31. /**
  32. * Interface IManager
  33. *
  34. * @since 6.0.0
  35. */
  36. interface IManager {
  37. /**
  38. * Generates a new IEvent object
  39. *
  40. * Make sure to call at least the following methods before sending it to the
  41. * app with via the publish() method:
  42. * - setApp()
  43. * - setType()
  44. * - setAffectedUser()
  45. * - setSubject()
  46. * - setObject()
  47. *
  48. * @return IEvent
  49. * @since 8.2.0
  50. */
  51. public function generateEvent(): IEvent;
  52. /**
  53. * Publish an event to the activity consumers
  54. *
  55. * Make sure to call at least the following methods before sending an Event:
  56. * - setApp()
  57. * - setType()
  58. * - setAffectedUser()
  59. * - setSubject()
  60. * - setObject()
  61. *
  62. * @param IEvent $event
  63. * @throws IncompleteActivityException if required values have not been set
  64. * @since 8.2.0
  65. * @since 30.0.0 throws {@see IncompleteActivityException} instead of \BadMethodCallException
  66. */
  67. public function publish(IEvent $event): void;
  68. /**
  69. * In order to improve lazy loading a closure can be registered which will be called in case
  70. * activity consumers are actually requested
  71. *
  72. * $callable has to return an instance of \OCP\Activity\IConsumer
  73. *
  74. * @param \Closure $callable
  75. * @since 6.0.0
  76. */
  77. public function registerConsumer(\Closure $callable): void;
  78. /**
  79. * @param string $filter Class must implement OCA\Activity\IFilter
  80. * @since 11.0.0
  81. */
  82. public function registerFilter(string $filter): void;
  83. /**
  84. * @return IFilter[]
  85. * @since 11.0.0
  86. */
  87. public function getFilters(): array;
  88. /**
  89. * @param string $id
  90. * @return IFilter
  91. * @throws FilterNotFoundException when the filter was not found
  92. * @since 11.0.0
  93. * @since 30.0.0 throws {@see FilterNotFoundException} instead of \InvalidArgumentException
  94. */
  95. public function getFilterById(string $id): IFilter;
  96. /**
  97. * @param string $setting Class must implement OCA\Activity\ISetting
  98. * @since 11.0.0
  99. */
  100. public function registerSetting(string $setting): void;
  101. /**
  102. * @return ActivitySettings[]
  103. * @since 11.0.0
  104. */
  105. public function getSettings(): array;
  106. /**
  107. * @param string $provider Class must implement OCA\Activity\IProvider
  108. * @since 11.0.0
  109. */
  110. public function registerProvider(string $provider): void;
  111. /**
  112. * @return IProvider[]
  113. * @since 11.0.0
  114. */
  115. public function getProviders(): array;
  116. /**
  117. * @param string $id
  118. * @return ActivitySettings
  119. * @throws SettingNotFoundException when the setting was not found
  120. * @since 11.0.0
  121. * @since 30.0.0 throws {@see SettingNotFoundException} instead of \InvalidArgumentException
  122. */
  123. public function getSettingById(string $id): ActivitySettings;
  124. /**
  125. * @param string $type
  126. * @param int $id
  127. * @since 8.2.0
  128. */
  129. public function setFormattingObject(string $type, int $id): void;
  130. /**
  131. * @return bool
  132. * @since 8.2.0
  133. */
  134. public function isFormattingFilteredObject(): bool;
  135. /**
  136. * @param bool $status Set to true, when parsing events should not use SVG icons
  137. * @since 12.0.1
  138. */
  139. public function setRequirePNG(bool $status): void;
  140. /**
  141. * @return bool
  142. * @since 12.0.1
  143. */
  144. public function getRequirePNG(): bool;
  145. /**
  146. * Set the user we need to use
  147. *
  148. * @param string|null $currentUserId
  149. * @since 9.0.1
  150. */
  151. public function setCurrentUserId(?string $currentUserId = null): void;
  152. /**
  153. * Get the user we need to use
  154. *
  155. * Either the user is logged in, or we try to get it from the token
  156. *
  157. * @return string
  158. * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
  159. * @since 8.1.0
  160. */
  161. public function getCurrentUserId(): string;
  162. }