1
0

IManager.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. /**
  29. * Interface IManager
  30. *
  31. * @since 6.0.0
  32. */
  33. interface IManager {
  34. /**
  35. * Generates a new IEvent object
  36. *
  37. * Make sure to call at least the following methods before sending it to the
  38. * app with via the publish() method:
  39. * - setApp()
  40. * - setType()
  41. * - setAffectedUser()
  42. * - setSubject()
  43. * - setObject()
  44. *
  45. * @return IEvent
  46. * @since 8.2.0
  47. */
  48. public function generateEvent(): IEvent;
  49. /**
  50. * Publish an event to the activity consumers
  51. *
  52. * Make sure to call at least the following methods before sending an Event:
  53. * - setApp()
  54. * - setType()
  55. * - setAffectedUser()
  56. * - setSubject()
  57. * - setObject()
  58. *
  59. * @param IEvent $event
  60. * @throws \BadMethodCallException if required values have not been set
  61. * @since 8.2.0
  62. */
  63. public function publish(IEvent $event): void;
  64. /**
  65. * In order to improve lazy loading a closure can be registered which will be called in case
  66. * activity consumers are actually requested
  67. *
  68. * $callable has to return an instance of \OCP\Activity\IConsumer
  69. *
  70. * @param \Closure $callable
  71. * @since 6.0.0
  72. */
  73. public function registerConsumer(\Closure $callable): void;
  74. /**
  75. * @param string $filter Class must implement OCA\Activity\IFilter
  76. * @since 11.0.0
  77. */
  78. public function registerFilter(string $filter): void;
  79. /**
  80. * @return IFilter[]
  81. * @since 11.0.0
  82. */
  83. public function getFilters(): array;
  84. /**
  85. * @param string $id
  86. * @return IFilter
  87. * @throws \InvalidArgumentException when the filter was not found
  88. * @since 11.0.0
  89. */
  90. public function getFilterById(string $id): IFilter;
  91. /**
  92. * @param string $setting Class must implement OCA\Activity\ISetting
  93. * @since 11.0.0
  94. */
  95. public function registerSetting(string $setting): void;
  96. /**
  97. * @return ActivitySettings[]
  98. * @since 11.0.0
  99. */
  100. public function getSettings(): array;
  101. /**
  102. * @param string $provider Class must implement OCA\Activity\IProvider
  103. * @since 11.0.0
  104. */
  105. public function registerProvider(string $provider): void;
  106. /**
  107. * @return IProvider[]
  108. * @since 11.0.0
  109. */
  110. public function getProviders(): array;
  111. /**
  112. * @param string $id
  113. * @return ActivitySettings
  114. * @throws \InvalidArgumentException when the setting was not found
  115. * @since 11.0.0
  116. */
  117. public function getSettingById(string $id): ActivitySettings;
  118. /**
  119. * @param string $type
  120. * @param int $id
  121. * @since 8.2.0
  122. */
  123. public function setFormattingObject(string $type, int $id): void;
  124. /**
  125. * @return bool
  126. * @since 8.2.0
  127. */
  128. public function isFormattingFilteredObject(): bool;
  129. /**
  130. * @param bool $status Set to true, when parsing events should not use SVG icons
  131. * @since 12.0.1
  132. */
  133. public function setRequirePNG(bool $status): void;
  134. /**
  135. * @return bool
  136. * @since 12.0.1
  137. */
  138. public function getRequirePNG(): bool;
  139. /**
  140. * Set the user we need to use
  141. *
  142. * @param string|null $currentUserId
  143. * @throws \UnexpectedValueException If the user is invalid
  144. * @since 9.0.1
  145. */
  146. public function setCurrentUserId(string $currentUserId = null): void;
  147. /**
  148. * Get the user we need to use
  149. *
  150. * Either the user is logged in, or we try to get it from the token
  151. *
  152. * @return string
  153. * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
  154. * @since 8.1.0
  155. */
  156. public function getCurrentUserId(): string;
  157. }