| @@ 98-114 (lines=17) @@ | ||
| 95 | /** |
|
| 96 | * @return \OCP\Activity\IConsumer[] |
|
| 97 | */ |
|
| 98 | protected function getConsumers() { |
|
| 99 | if (!empty($this->consumers)) { |
|
| 100 | return $this->consumers; |
|
| 101 | } |
|
| 102 | ||
| 103 | $this->consumers = []; |
|
| 104 | foreach($this->consumersClosures as $consumer) { |
|
| 105 | $c = $consumer(); |
|
| 106 | if ($c instanceof IConsumer) { |
|
| 107 | $this->consumers[] = $c; |
|
| 108 | } else { |
|
| 109 | throw new \InvalidArgumentException('The given consumer does not implement the \OCP\Activity\IConsumer interface'); |
|
| 110 | } |
|
| 111 | } |
|
| 112 | ||
| 113 | return $this->consumers; |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * @return \OCP\Activity\IExtension[] |
|
| @@ 119-135 (lines=17) @@ | ||
| 116 | /** |
|
| 117 | * @return \OCP\Activity\IExtension[] |
|
| 118 | */ |
|
| 119 | protected function getExtensions() { |
|
| 120 | if (!empty($this->extensions)) { |
|
| 121 | return $this->extensions; |
|
| 122 | } |
|
| 123 | ||
| 124 | $this->extensions = []; |
|
| 125 | foreach($this->extensionsClosures as $extension) { |
|
| 126 | $e = $extension(); |
|
| 127 | if ($e instanceof IExtension) { |
|
| 128 | $this->extensions[] = $e; |
|
| 129 | } else { |
|
| 130 | throw new \InvalidArgumentException('The given extension does not implement the \OCP\Activity\IExtension interface'); |
|
| 131 | } |
|
| 132 | } |
|
| 133 | ||
| 134 | return $this->extensions; |
|
| 135 | } |
|
| 136 | ||
| 137 | /** |
|
| 138 | * Generates a new IEvent object |
|
| @@ 87-102 (lines=16) @@ | ||
| 84 | /** |
|
| 85 | * @return IApp[] |
|
| 86 | */ |
|
| 87 | protected function getApps() { |
|
| 88 | if (!empty($this->apps)) { |
|
| 89 | return $this->apps; |
|
| 90 | } |
|
| 91 | ||
| 92 | $this->apps = []; |
|
| 93 | foreach ($this->appsClosures as $closure) { |
|
| 94 | $app = $closure(); |
|
| 95 | if (!($app instanceof IApp)) { |
|
| 96 | throw new \InvalidArgumentException('The given notification app does not implement the IApp interface'); |
|
| 97 | } |
|
| 98 | $this->apps[] = $app; |
|
| 99 | } |
|
| 100 | ||
| 101 | return $this->apps; |
|
| 102 | } |
|
| 103 | ||
| 104 | /** |
|
| 105 | * @return INotifier[] |
|
| @@ 107-122 (lines=16) @@ | ||
| 104 | /** |
|
| 105 | * @return INotifier[] |
|
| 106 | */ |
|
| 107 | protected function getNotifiers() { |
|
| 108 | if (!empty($this->notifiers)) { |
|
| 109 | return $this->notifiers; |
|
| 110 | } |
|
| 111 | ||
| 112 | $this->notifiers = []; |
|
| 113 | foreach ($this->notifiersClosures as $closure) { |
|
| 114 | $notifier = $closure(); |
|
| 115 | if (!($notifier instanceof INotifier)) { |
|
| 116 | throw new \InvalidArgumentException('The given notifier does not implement the INotifier interface'); |
|
| 117 | } |
|
| 118 | $this->notifiers[] = $notifier; |
|
| 119 | } |
|
| 120 | ||
| 121 | return $this->notifiers; |
|
| 122 | } |
|
| 123 | ||
| 124 | /** |
|
| 125 | * @return array[] |
|
| @@ 814-829 (lines=16) @@ | ||
| 811 | * |
|
| 812 | * @return \OCP\Comments\ICommentsEventHandler[] |
|
| 813 | */ |
|
| 814 | private function getEventHandlers() { |
|
| 815 | if(!empty($this->eventHandlers)) { |
|
| 816 | return $this->eventHandlers; |
|
| 817 | } |
|
| 818 | ||
| 819 | $this->eventHandlers = []; |
|
| 820 | foreach ($this->eventHandlerClosures as $name => $closure) { |
|
| 821 | $entity = $closure(); |
|
| 822 | if (!($entity instanceof ICommentsEventHandler)) { |
|
| 823 | throw new \InvalidArgumentException('The given entity does not implement the ICommentsEntity interface'); |
|
| 824 | } |
|
| 825 | $this->eventHandlers[$name] = $entity; |
|
| 826 | } |
|
| 827 | ||
| 828 | return $this->eventHandlers; |
|
| 829 | } |
|
| 830 | ||
| 831 | /** |
|
| 832 | * sends notifications to the registered entities |
|