| @@ 113-129 (lines=17) @@ | ||
| 110 | /** |
|
| 111 | * @return \OCP\Activity\IConsumer[] |
|
| 112 | */ |
|
| 113 | protected function getConsumers() { |
|
| 114 | if (!empty($this->consumers)) { |
|
| 115 | return $this->consumers; |
|
| 116 | } |
|
| 117 | ||
| 118 | $this->consumers = []; |
|
| 119 | foreach($this->consumersClosures as $consumer) { |
|
| 120 | $c = $consumer(); |
|
| 121 | if ($c instanceof IConsumer) { |
|
| 122 | $this->consumers[] = $c; |
|
| 123 | } else { |
|
| 124 | throw new \InvalidArgumentException('The given consumer does not implement the \OCP\Activity\IConsumer interface'); |
|
| 125 | } |
|
| 126 | } |
|
| 127 | ||
| 128 | return $this->consumers; |
|
| 129 | } |
|
| 130 | ||
| 131 | /** |
|
| 132 | * @return \OCP\Activity\IExtension[] |
|
| @@ 134-150 (lines=17) @@ | ||
| 131 | /** |
|
| 132 | * @return \OCP\Activity\IExtension[] |
|
| 133 | */ |
|
| 134 | protected function getExtensions() { |
|
| 135 | if (!empty($this->extensions)) { |
|
| 136 | return $this->extensions; |
|
| 137 | } |
|
| 138 | ||
| 139 | $this->extensions = []; |
|
| 140 | foreach($this->extensionsClosures as $extension) { |
|
| 141 | $e = $extension(); |
|
| 142 | if ($e instanceof IExtension) { |
|
| 143 | $this->extensions[] = $e; |
|
| 144 | } else { |
|
| 145 | throw new \InvalidArgumentException('The given extension does not implement the \OCP\Activity\IExtension interface'); |
|
| 146 | } |
|
| 147 | } |
|
| 148 | ||
| 149 | return $this->extensions; |
|
| 150 | } |
|
| 151 | ||
| 152 | /** |
|
| 153 | * Generates a new IEvent object |
|
| @@ 102-117 (lines=16) @@ | ||
| 99 | /** |
|
| 100 | * @return IApp[] |
|
| 101 | */ |
|
| 102 | protected function getApps(): array { |
|
| 103 | if (!empty($this->apps)) { |
|
| 104 | return $this->apps; |
|
| 105 | } |
|
| 106 | ||
| 107 | $this->apps = []; |
|
| 108 | foreach ($this->appsClosures as $closure) { |
|
| 109 | $app = $closure(); |
|
| 110 | if (!($app instanceof IApp)) { |
|
| 111 | throw new \InvalidArgumentException('The given notification app does not implement the IApp interface'); |
|
| 112 | } |
|
| 113 | $this->apps[] = $app; |
|
| 114 | } |
|
| 115 | ||
| 116 | return $this->apps; |
|
| 117 | } |
|
| 118 | ||
| 119 | /** |
|
| 120 | * @return INotifier[] |
|
| @@ 122-137 (lines=16) @@ | ||
| 119 | /** |
|
| 120 | * @return INotifier[] |
|
| 121 | */ |
|
| 122 | protected function getNotifiers(): array { |
|
| 123 | if (!empty($this->notifiers)) { |
|
| 124 | return $this->notifiers; |
|
| 125 | } |
|
| 126 | ||
| 127 | $this->notifiers = []; |
|
| 128 | foreach ($this->notifiersClosures as $closure) { |
|
| 129 | $notifier = $closure(); |
|
| 130 | if (!($notifier instanceof INotifier)) { |
|
| 131 | throw new \InvalidArgumentException('The given notifier does not implement the INotifier interface'); |
|
| 132 | } |
|
| 133 | $this->notifiers[] = $notifier; |
|
| 134 | } |
|
| 135 | ||
| 136 | return $this->notifiers; |
|
| 137 | } |
|
| 138 | ||
| 139 | /** |
|
| 140 | * @return array[] |
|
| @@ 1030-1045 (lines=16) @@ | ||
| 1027 | * |
|
| 1028 | * @return \OCP\Comments\ICommentsEventHandler[] |
|
| 1029 | */ |
|
| 1030 | private function getEventHandlers() { |
|
| 1031 | if (!empty($this->eventHandlers)) { |
|
| 1032 | return $this->eventHandlers; |
|
| 1033 | } |
|
| 1034 | ||
| 1035 | $this->eventHandlers = []; |
|
| 1036 | foreach ($this->eventHandlerClosures as $name => $closure) { |
|
| 1037 | $entity = $closure(); |
|
| 1038 | if (!($entity instanceof ICommentsEventHandler)) { |
|
| 1039 | throw new \InvalidArgumentException('The given entity does not implement the ICommentsEntity interface'); |
|
| 1040 | } |
|
| 1041 | $this->eventHandlers[$name] = $entity; |
|
| 1042 | } |
|
| 1043 | ||
| 1044 | return $this->eventHandlers; |
|
| 1045 | } |
|
| 1046 | ||
| 1047 | /** |
|
| 1048 | * sends notifications to the registered entities |
|