IManager.php 4.2 KB

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