| @@ 97-112 (lines=16) @@ | ||
| 94 | /** |
|
| 95 | * @return IApp[] |
|
| 96 | */ |
|
| 97 | protected function getApps() { |
|
| 98 | if (!empty($this->apps)) { |
|
| 99 | return $this->apps; |
|
| 100 | } |
|
| 101 | ||
| 102 | $this->apps = []; |
|
| 103 | foreach ($this->appsClosures as $closure) { |
|
| 104 | $app = $closure(); |
|
| 105 | if (!($app instanceof IApp)) { |
|
| 106 | throw new \InvalidArgumentException('The given notification app does not implement the IApp interface'); |
|
| 107 | } |
|
| 108 | $this->apps[] = $app; |
|
| 109 | } |
|
| 110 | ||
| 111 | return $this->apps; |
|
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * @return INotifier[] |
|
| @@ 117-132 (lines=16) @@ | ||
| 114 | /** |
|
| 115 | * @return INotifier[] |
|
| 116 | */ |
|
| 117 | protected function getNotifiers() { |
|
| 118 | if (!empty($this->notifiers)) { |
|
| 119 | return $this->notifiers; |
|
| 120 | } |
|
| 121 | ||
| 122 | $this->notifiers = []; |
|
| 123 | foreach ($this->notifiersClosures as $closure) { |
|
| 124 | $notifier = $closure(); |
|
| 125 | if (!($notifier instanceof INotifier)) { |
|
| 126 | throw new \InvalidArgumentException('The given notifier does not implement the INotifier interface'); |
|
| 127 | } |
|
| 128 | $this->notifiers[] = $notifier; |
|
| 129 | } |
|
| 130 | ||
| 131 | return $this->notifiers; |
|
| 132 | } |
|
| 133 | ||
| 134 | /** |
|
| 135 | * @return array[] |
|
| @@ 112-128 (lines=17) @@ | ||
| 109 | /** |
|
| 110 | * @return \OCP\Activity\IConsumer[] |
|
| 111 | */ |
|
| 112 | protected function getConsumers() { |
|
| 113 | if (!empty($this->consumers)) { |
|
| 114 | return $this->consumers; |
|
| 115 | } |
|
| 116 | ||
| 117 | $this->consumers = []; |
|
| 118 | foreach($this->consumersClosures as $consumer) { |
|
| 119 | $c = $consumer(); |
|
| 120 | if ($c instanceof IConsumer) { |
|
| 121 | $this->consumers[] = $c; |
|
| 122 | } else { |
|
| 123 | throw new \InvalidArgumentException('The given consumer does not implement the \OCP\Activity\IConsumer interface'); |
|
| 124 | } |
|
| 125 | } |
|
| 126 | ||
| 127 | return $this->consumers; |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * @return \OCP\Activity\IExtension[] |
|
| @@ 133-149 (lines=17) @@ | ||
| 130 | /** |
|
| 131 | * @return \OCP\Activity\IExtension[] |
|
| 132 | */ |
|
| 133 | protected function getExtensions() { |
|
| 134 | if (!empty($this->extensions)) { |
|
| 135 | return $this->extensions; |
|
| 136 | } |
|
| 137 | ||
| 138 | $this->extensions = []; |
|
| 139 | foreach($this->extensionsClosures as $extension) { |
|
| 140 | $e = $extension(); |
|
| 141 | if ($e instanceof IExtension) { |
|
| 142 | $this->extensions[] = $e; |
|
| 143 | } else { |
|
| 144 | throw new \InvalidArgumentException('The given extension does not implement the \OCP\Activity\IExtension interface'); |
|
| 145 | } |
|
| 146 | } |
|
| 147 | ||
| 148 | return $this->extensions; |
|
| 149 | } |
|
| 150 | ||
| 151 | /** |
|
| 152 | * Generates a new IEvent object |
|
| @@ 857-872 (lines=16) @@ | ||
| 854 | * |
|
| 855 | * @return \OCP\Comments\ICommentsEventHandler[] |
|
| 856 | */ |
|
| 857 | private function getEventHandlers() { |
|
| 858 | if (!empty($this->eventHandlers)) { |
|
| 859 | return $this->eventHandlers; |
|
| 860 | } |
|
| 861 | ||
| 862 | $this->eventHandlers = []; |
|
| 863 | foreach ($this->eventHandlerClosures as $name => $closure) { |
|
| 864 | $entity = $closure(); |
|
| 865 | if (!($entity instanceof ICommentsEventHandler)) { |
|
| 866 | throw new \InvalidArgumentException('The given entity does not implement the ICommentsEntity interface'); |
|
| 867 | } |
|
| 868 | $this->eventHandlers[$name] = $entity; |
|
| 869 | } |
|
| 870 | ||
| 871 | return $this->eventHandlers; |
|
| 872 | } |
|
| 873 | ||
| 874 | /** |
|
| 875 | * sends notifications to the registered entities |
|