@@ -38,284 +38,284 @@ |
||
| 38 | 38 | * @since 8.2.0 |
| 39 | 39 | */ |
| 40 | 40 | interface IEvent { |
| 41 | - /** |
|
| 42 | - * Set the app of the activity |
|
| 43 | - * |
|
| 44 | - * @param string $app |
|
| 45 | - * @return IEvent |
|
| 46 | - * @throws \InvalidArgumentException if the app id is invalid |
|
| 47 | - * @since 8.2.0 |
|
| 48 | - */ |
|
| 49 | - public function setApp(string $app): self; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Set the type of the activity |
|
| 53 | - * |
|
| 54 | - * @param string $type |
|
| 55 | - * @return IEvent |
|
| 56 | - * @throws \InvalidArgumentException if the type is invalid |
|
| 57 | - * @since 8.2.0 |
|
| 58 | - */ |
|
| 59 | - public function setType(string $type): self; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Set the affected user of the activity |
|
| 63 | - * |
|
| 64 | - * @param string $user |
|
| 65 | - * @return IEvent |
|
| 66 | - * @throws \InvalidArgumentException if the affected user is invalid |
|
| 67 | - * @since 8.2.0 |
|
| 68 | - */ |
|
| 69 | - public function setAffectedUser(string $user): self; |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Set the author of the activity |
|
| 73 | - * |
|
| 74 | - * @param string $author |
|
| 75 | - * @return IEvent |
|
| 76 | - * @throws \InvalidArgumentException if the author is invalid |
|
| 77 | - * @since 8.2.0 |
|
| 78 | - */ |
|
| 79 | - public function setAuthor(string $author): self; |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Set the author of the activity |
|
| 83 | - * |
|
| 84 | - * @param int $timestamp |
|
| 85 | - * @return IEvent |
|
| 86 | - * @throws \InvalidArgumentException if the timestamp is invalid |
|
| 87 | - * @since 8.2.0 |
|
| 88 | - */ |
|
| 89 | - public function setTimestamp(int $timestamp): self; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Set the subject of the activity |
|
| 93 | - * |
|
| 94 | - * @param string $subject |
|
| 95 | - * @param array $parameters |
|
| 96 | - * @return IEvent |
|
| 97 | - * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 98 | - * @since 8.2.0 |
|
| 99 | - */ |
|
| 100 | - public function setSubject(string $subject, array $parameters = []): self; |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @param string $subject |
|
| 104 | - * @return $this |
|
| 105 | - * @throws \InvalidArgumentException if the subject is invalid |
|
| 106 | - * @since 11.0.0 |
|
| 107 | - */ |
|
| 108 | - public function setParsedSubject(string $subject): self; |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @return string |
|
| 112 | - * @since 11.0.0 |
|
| 113 | - */ |
|
| 114 | - public function getParsedSubject(): string; |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * @param string $subject |
|
| 118 | - * @param array $parameters |
|
| 119 | - * @return $this |
|
| 120 | - * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 121 | - * @since 11.0.0 |
|
| 122 | - */ |
|
| 123 | - public function setRichSubject(string $subject, array $parameters = []): self; |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @return string |
|
| 127 | - * @since 11.0.0 |
|
| 128 | - */ |
|
| 129 | - public function getRichSubject(): string; |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @return array[] |
|
| 133 | - * @since 11.0.0 |
|
| 134 | - */ |
|
| 135 | - public function getRichSubjectParameters(): array; |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * Set the message of the activity |
|
| 139 | - * |
|
| 140 | - * @param string $message |
|
| 141 | - * @param array $parameters |
|
| 142 | - * @return IEvent |
|
| 143 | - * @throws \InvalidArgumentException if the message or parameters are invalid |
|
| 144 | - * @since 8.2.0 |
|
| 145 | - */ |
|
| 146 | - public function setMessage(string $message, array $parameters = []): self; |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @param string $message |
|
| 150 | - * @return $this |
|
| 151 | - * @throws \InvalidArgumentException if the message is invalid |
|
| 152 | - * @since 11.0.0 |
|
| 153 | - */ |
|
| 154 | - public function setParsedMessage(string $message): self; |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * @return string |
|
| 158 | - * @since 11.0.0 |
|
| 159 | - */ |
|
| 160 | - public function getParsedMessage(): string; |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @param string $message |
|
| 164 | - * @param array $parameters |
|
| 165 | - * @return $this |
|
| 166 | - * @throws \InvalidArgumentException if the message or parameters are invalid |
|
| 167 | - * @since 11.0.0 |
|
| 168 | - */ |
|
| 169 | - public function setRichMessage(string $message, array $parameters = []): self; |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * @return string |
|
| 173 | - * @since 11.0.0 |
|
| 174 | - */ |
|
| 175 | - public function getRichMessage(): string; |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * @return array[] |
|
| 179 | - * @since 11.0.0 |
|
| 180 | - */ |
|
| 181 | - public function getRichMessageParameters(): array; |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * Set the object of the activity |
|
| 185 | - * |
|
| 186 | - * @param string $objectType |
|
| 187 | - * @param int $objectId |
|
| 188 | - * @param string $objectName |
|
| 189 | - * @return IEvent |
|
| 190 | - * @throws \InvalidArgumentException if the object is invalid |
|
| 191 | - * @since 8.2.0 |
|
| 192 | - */ |
|
| 193 | - public function setObject(string $objectType, int $objectId, string $objectName = ''): self; |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Set the link of the activity |
|
| 197 | - * |
|
| 198 | - * @param string $link |
|
| 199 | - * @return IEvent |
|
| 200 | - * @throws \InvalidArgumentException if the link is invalid |
|
| 201 | - * @since 8.2.0 |
|
| 202 | - */ |
|
| 203 | - public function setLink(string $link): self; |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * @return string |
|
| 207 | - * @since 8.2.0 |
|
| 208 | - */ |
|
| 209 | - public function getApp(): string; |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * @return string |
|
| 213 | - * @since 8.2.0 |
|
| 214 | - */ |
|
| 215 | - public function getType(): string; |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * @return string |
|
| 219 | - * @since 8.2.0 |
|
| 220 | - */ |
|
| 221 | - public function getAffectedUser(): string; |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * @return string |
|
| 225 | - * @since 8.2.0 |
|
| 226 | - */ |
|
| 227 | - public function getAuthor(): string; |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * @return int |
|
| 231 | - * @since 8.2.0 |
|
| 232 | - */ |
|
| 233 | - public function getTimestamp(): int; |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * @return string |
|
| 237 | - * @since 8.2.0 |
|
| 238 | - */ |
|
| 239 | - public function getSubject(): string; |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * @return array |
|
| 243 | - * @since 8.2.0 |
|
| 244 | - */ |
|
| 245 | - public function getSubjectParameters(): array; |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * @return string |
|
| 249 | - * @since 8.2.0 |
|
| 250 | - */ |
|
| 251 | - public function getMessage(): string; |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * @return array |
|
| 255 | - * @since 8.2.0 |
|
| 256 | - */ |
|
| 257 | - public function getMessageParameters(): array; |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * @return string |
|
| 261 | - * @since 8.2.0 |
|
| 262 | - */ |
|
| 263 | - public function getObjectType(): string; |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * @return int |
|
| 267 | - * @since 8.2.0 |
|
| 268 | - */ |
|
| 269 | - public function getObjectId(): int; |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * @return string |
|
| 273 | - * @since 8.2.0 |
|
| 274 | - */ |
|
| 275 | - public function getObjectName(): string; |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * @return string |
|
| 279 | - * @since 8.2.0 |
|
| 280 | - */ |
|
| 281 | - public function getLink(): string; |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * @param string $icon |
|
| 285 | - * @return $this |
|
| 286 | - * @throws \InvalidArgumentException if the icon is invalid |
|
| 287 | - * @since 11.0.0 |
|
| 288 | - */ |
|
| 289 | - public function setIcon(string $icon): self; |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * @return string |
|
| 293 | - * @since 11.0.0 |
|
| 294 | - */ |
|
| 295 | - public function getIcon(): string; |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * @param IEvent $child |
|
| 299 | - * @return $this |
|
| 300 | - * @since 11.0.0 - Since 15.0.0 returns $this |
|
| 301 | - */ |
|
| 302 | - public function setChildEvent(IEvent $child): self; |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * @return IEvent|null |
|
| 306 | - * @since 11.0.0 |
|
| 307 | - */ |
|
| 308 | - public function getChildEvent(); |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * @return bool |
|
| 312 | - * @since 11.0.0 |
|
| 313 | - */ |
|
| 314 | - public function isValid(): bool; |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * @return bool |
|
| 318 | - * @since 11.0.0 |
|
| 319 | - */ |
|
| 320 | - public function isValidParsed(): bool; |
|
| 41 | + /** |
|
| 42 | + * Set the app of the activity |
|
| 43 | + * |
|
| 44 | + * @param string $app |
|
| 45 | + * @return IEvent |
|
| 46 | + * @throws \InvalidArgumentException if the app id is invalid |
|
| 47 | + * @since 8.2.0 |
|
| 48 | + */ |
|
| 49 | + public function setApp(string $app): self; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Set the type of the activity |
|
| 53 | + * |
|
| 54 | + * @param string $type |
|
| 55 | + * @return IEvent |
|
| 56 | + * @throws \InvalidArgumentException if the type is invalid |
|
| 57 | + * @since 8.2.0 |
|
| 58 | + */ |
|
| 59 | + public function setType(string $type): self; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Set the affected user of the activity |
|
| 63 | + * |
|
| 64 | + * @param string $user |
|
| 65 | + * @return IEvent |
|
| 66 | + * @throws \InvalidArgumentException if the affected user is invalid |
|
| 67 | + * @since 8.2.0 |
|
| 68 | + */ |
|
| 69 | + public function setAffectedUser(string $user): self; |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Set the author of the activity |
|
| 73 | + * |
|
| 74 | + * @param string $author |
|
| 75 | + * @return IEvent |
|
| 76 | + * @throws \InvalidArgumentException if the author is invalid |
|
| 77 | + * @since 8.2.0 |
|
| 78 | + */ |
|
| 79 | + public function setAuthor(string $author): self; |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Set the author of the activity |
|
| 83 | + * |
|
| 84 | + * @param int $timestamp |
|
| 85 | + * @return IEvent |
|
| 86 | + * @throws \InvalidArgumentException if the timestamp is invalid |
|
| 87 | + * @since 8.2.0 |
|
| 88 | + */ |
|
| 89 | + public function setTimestamp(int $timestamp): self; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Set the subject of the activity |
|
| 93 | + * |
|
| 94 | + * @param string $subject |
|
| 95 | + * @param array $parameters |
|
| 96 | + * @return IEvent |
|
| 97 | + * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 98 | + * @since 8.2.0 |
|
| 99 | + */ |
|
| 100 | + public function setSubject(string $subject, array $parameters = []): self; |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @param string $subject |
|
| 104 | + * @return $this |
|
| 105 | + * @throws \InvalidArgumentException if the subject is invalid |
|
| 106 | + * @since 11.0.0 |
|
| 107 | + */ |
|
| 108 | + public function setParsedSubject(string $subject): self; |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @return string |
|
| 112 | + * @since 11.0.0 |
|
| 113 | + */ |
|
| 114 | + public function getParsedSubject(): string; |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * @param string $subject |
|
| 118 | + * @param array $parameters |
|
| 119 | + * @return $this |
|
| 120 | + * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 121 | + * @since 11.0.0 |
|
| 122 | + */ |
|
| 123 | + public function setRichSubject(string $subject, array $parameters = []): self; |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @return string |
|
| 127 | + * @since 11.0.0 |
|
| 128 | + */ |
|
| 129 | + public function getRichSubject(): string; |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @return array[] |
|
| 133 | + * @since 11.0.0 |
|
| 134 | + */ |
|
| 135 | + public function getRichSubjectParameters(): array; |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * Set the message of the activity |
|
| 139 | + * |
|
| 140 | + * @param string $message |
|
| 141 | + * @param array $parameters |
|
| 142 | + * @return IEvent |
|
| 143 | + * @throws \InvalidArgumentException if the message or parameters are invalid |
|
| 144 | + * @since 8.2.0 |
|
| 145 | + */ |
|
| 146 | + public function setMessage(string $message, array $parameters = []): self; |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * @param string $message |
|
| 150 | + * @return $this |
|
| 151 | + * @throws \InvalidArgumentException if the message is invalid |
|
| 152 | + * @since 11.0.0 |
|
| 153 | + */ |
|
| 154 | + public function setParsedMessage(string $message): self; |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * @return string |
|
| 158 | + * @since 11.0.0 |
|
| 159 | + */ |
|
| 160 | + public function getParsedMessage(): string; |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * @param string $message |
|
| 164 | + * @param array $parameters |
|
| 165 | + * @return $this |
|
| 166 | + * @throws \InvalidArgumentException if the message or parameters are invalid |
|
| 167 | + * @since 11.0.0 |
|
| 168 | + */ |
|
| 169 | + public function setRichMessage(string $message, array $parameters = []): self; |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * @return string |
|
| 173 | + * @since 11.0.0 |
|
| 174 | + */ |
|
| 175 | + public function getRichMessage(): string; |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * @return array[] |
|
| 179 | + * @since 11.0.0 |
|
| 180 | + */ |
|
| 181 | + public function getRichMessageParameters(): array; |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * Set the object of the activity |
|
| 185 | + * |
|
| 186 | + * @param string $objectType |
|
| 187 | + * @param int $objectId |
|
| 188 | + * @param string $objectName |
|
| 189 | + * @return IEvent |
|
| 190 | + * @throws \InvalidArgumentException if the object is invalid |
|
| 191 | + * @since 8.2.0 |
|
| 192 | + */ |
|
| 193 | + public function setObject(string $objectType, int $objectId, string $objectName = ''): self; |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Set the link of the activity |
|
| 197 | + * |
|
| 198 | + * @param string $link |
|
| 199 | + * @return IEvent |
|
| 200 | + * @throws \InvalidArgumentException if the link is invalid |
|
| 201 | + * @since 8.2.0 |
|
| 202 | + */ |
|
| 203 | + public function setLink(string $link): self; |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * @return string |
|
| 207 | + * @since 8.2.0 |
|
| 208 | + */ |
|
| 209 | + public function getApp(): string; |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * @return string |
|
| 213 | + * @since 8.2.0 |
|
| 214 | + */ |
|
| 215 | + public function getType(): string; |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * @return string |
|
| 219 | + * @since 8.2.0 |
|
| 220 | + */ |
|
| 221 | + public function getAffectedUser(): string; |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * @return string |
|
| 225 | + * @since 8.2.0 |
|
| 226 | + */ |
|
| 227 | + public function getAuthor(): string; |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * @return int |
|
| 231 | + * @since 8.2.0 |
|
| 232 | + */ |
|
| 233 | + public function getTimestamp(): int; |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * @return string |
|
| 237 | + * @since 8.2.0 |
|
| 238 | + */ |
|
| 239 | + public function getSubject(): string; |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * @return array |
|
| 243 | + * @since 8.2.0 |
|
| 244 | + */ |
|
| 245 | + public function getSubjectParameters(): array; |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * @return string |
|
| 249 | + * @since 8.2.0 |
|
| 250 | + */ |
|
| 251 | + public function getMessage(): string; |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * @return array |
|
| 255 | + * @since 8.2.0 |
|
| 256 | + */ |
|
| 257 | + public function getMessageParameters(): array; |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * @return string |
|
| 261 | + * @since 8.2.0 |
|
| 262 | + */ |
|
| 263 | + public function getObjectType(): string; |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * @return int |
|
| 267 | + * @since 8.2.0 |
|
| 268 | + */ |
|
| 269 | + public function getObjectId(): int; |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * @return string |
|
| 273 | + * @since 8.2.0 |
|
| 274 | + */ |
|
| 275 | + public function getObjectName(): string; |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * @return string |
|
| 279 | + * @since 8.2.0 |
|
| 280 | + */ |
|
| 281 | + public function getLink(): string; |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * @param string $icon |
|
| 285 | + * @return $this |
|
| 286 | + * @throws \InvalidArgumentException if the icon is invalid |
|
| 287 | + * @since 11.0.0 |
|
| 288 | + */ |
|
| 289 | + public function setIcon(string $icon): self; |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * @return string |
|
| 293 | + * @since 11.0.0 |
|
| 294 | + */ |
|
| 295 | + public function getIcon(): string; |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * @param IEvent $child |
|
| 299 | + * @return $this |
|
| 300 | + * @since 11.0.0 - Since 15.0.0 returns $this |
|
| 301 | + */ |
|
| 302 | + public function setChildEvent(IEvent $child): self; |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * @return IEvent|null |
|
| 306 | + * @since 11.0.0 |
|
| 307 | + */ |
|
| 308 | + public function getChildEvent(); |
|
| 309 | + |
|
| 310 | + /** |
|
| 311 | + * @return bool |
|
| 312 | + * @since 11.0.0 |
|
| 313 | + */ |
|
| 314 | + public function isValid(): bool; |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * @return bool |
|
| 318 | + * @since 11.0.0 |
|
| 319 | + */ |
|
| 320 | + public function isValidParsed(): bool; |
|
| 321 | 321 | } |
@@ -31,502 +31,502 @@ |
||
| 31 | 31 | |
| 32 | 32 | class Event implements IEvent { |
| 33 | 33 | |
| 34 | - /** @var string */ |
|
| 35 | - protected $app = ''; |
|
| 36 | - /** @var string */ |
|
| 37 | - protected $type = ''; |
|
| 38 | - /** @var string */ |
|
| 39 | - protected $affectedUser = ''; |
|
| 40 | - /** @var string */ |
|
| 41 | - protected $author = ''; |
|
| 42 | - /** @var int */ |
|
| 43 | - protected $timestamp = 0; |
|
| 44 | - /** @var string */ |
|
| 45 | - protected $subject = ''; |
|
| 46 | - /** @var array */ |
|
| 47 | - protected $subjectParameters = []; |
|
| 48 | - /** @var string */ |
|
| 49 | - protected $subjectParsed; |
|
| 50 | - /** @var string */ |
|
| 51 | - protected $subjectRich; |
|
| 52 | - /** @var array */ |
|
| 53 | - protected $subjectRichParameters; |
|
| 54 | - /** @var string */ |
|
| 55 | - protected $message = ''; |
|
| 56 | - /** @var array */ |
|
| 57 | - protected $messageParameters = []; |
|
| 58 | - /** @var string */ |
|
| 59 | - protected $messageParsed; |
|
| 60 | - /** @var string */ |
|
| 61 | - protected $messageRich; |
|
| 62 | - /** @var array */ |
|
| 63 | - protected $messageRichParameters; |
|
| 64 | - /** @var string */ |
|
| 65 | - protected $objectType = ''; |
|
| 66 | - /** @var int */ |
|
| 67 | - protected $objectId = 0; |
|
| 68 | - /** @var string */ |
|
| 69 | - protected $objectName = ''; |
|
| 70 | - /** @var string */ |
|
| 71 | - protected $link = ''; |
|
| 72 | - /** @var string */ |
|
| 73 | - protected $icon = ''; |
|
| 74 | - |
|
| 75 | - /** @var IEvent|null */ |
|
| 76 | - protected $child; |
|
| 77 | - /** @var IValidator */ |
|
| 78 | - protected $richValidator; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @param IValidator $richValidator |
|
| 82 | - */ |
|
| 83 | - public function __construct(IValidator $richValidator) { |
|
| 84 | - $this->richValidator = $richValidator; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Set the app of the activity |
|
| 89 | - * |
|
| 90 | - * @param string $app |
|
| 91 | - * @return IEvent |
|
| 92 | - * @throws \InvalidArgumentException if the app id is invalid |
|
| 93 | - * @since 8.2.0 |
|
| 94 | - */ |
|
| 95 | - public function setApp(string $app): IEvent { |
|
| 96 | - if ($app === '' || isset($app[32])) { |
|
| 97 | - throw new \InvalidArgumentException('The given app is invalid'); |
|
| 98 | - } |
|
| 99 | - $this->app = $app; |
|
| 100 | - return $this; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @return string |
|
| 105 | - */ |
|
| 106 | - public function getApp(): string { |
|
| 107 | - return $this->app; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Set the type of the activity |
|
| 112 | - * |
|
| 113 | - * @param string $type |
|
| 114 | - * @return IEvent |
|
| 115 | - * @throws \InvalidArgumentException if the type is invalid |
|
| 116 | - * @since 8.2.0 |
|
| 117 | - */ |
|
| 118 | - public function setType(string $type): IEvent { |
|
| 119 | - if ($type === '' || isset($type[255])) { |
|
| 120 | - throw new \InvalidArgumentException('The given type is invalid'); |
|
| 121 | - } |
|
| 122 | - $this->type = $type; |
|
| 123 | - return $this; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * @return string |
|
| 128 | - */ |
|
| 129 | - public function getType(): string { |
|
| 130 | - return $this->type; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Set the affected user of the activity |
|
| 135 | - * |
|
| 136 | - * @param string $affectedUser |
|
| 137 | - * @return IEvent |
|
| 138 | - * @throws \InvalidArgumentException if the affected user is invalid |
|
| 139 | - * @since 8.2.0 |
|
| 140 | - */ |
|
| 141 | - public function setAffectedUser(string $affectedUser): IEvent { |
|
| 142 | - if ($affectedUser === '' || isset($affectedUser[64])) { |
|
| 143 | - throw new \InvalidArgumentException('The given affected user is invalid'); |
|
| 144 | - } |
|
| 145 | - $this->affectedUser = $affectedUser; |
|
| 146 | - return $this; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * @return string |
|
| 151 | - */ |
|
| 152 | - public function getAffectedUser(): string { |
|
| 153 | - return $this->affectedUser; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Set the author of the activity |
|
| 158 | - * |
|
| 159 | - * @param string $author |
|
| 160 | - * @return IEvent |
|
| 161 | - * @throws \InvalidArgumentException if the author is invalid |
|
| 162 | - * @since 8.2.0 |
|
| 163 | - */ |
|
| 164 | - public function setAuthor(string $author): IEvent { |
|
| 165 | - if (isset($author[64])) { |
|
| 166 | - throw new \InvalidArgumentException('The given author user is invalid'); |
|
| 167 | - } |
|
| 168 | - $this->author = $author; |
|
| 169 | - return $this; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * @return string |
|
| 174 | - */ |
|
| 175 | - public function getAuthor(): string { |
|
| 176 | - return $this->author; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * Set the timestamp of the activity |
|
| 181 | - * |
|
| 182 | - * @param int $timestamp |
|
| 183 | - * @return IEvent |
|
| 184 | - * @throws \InvalidArgumentException if the timestamp is invalid |
|
| 185 | - * @since 8.2.0 |
|
| 186 | - */ |
|
| 187 | - public function setTimestamp(int $timestamp): IEvent { |
|
| 188 | - $this->timestamp = $timestamp; |
|
| 189 | - return $this; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * @return int |
|
| 194 | - */ |
|
| 195 | - public function getTimestamp(): int { |
|
| 196 | - return $this->timestamp; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * Set the subject of the activity |
|
| 201 | - * |
|
| 202 | - * @param string $subject |
|
| 203 | - * @param array $parameters |
|
| 204 | - * @return IEvent |
|
| 205 | - * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 206 | - * @since 8.2.0 |
|
| 207 | - */ |
|
| 208 | - public function setSubject(string $subject, array $parameters = []): IEvent { |
|
| 209 | - if (isset($subject[255])) { |
|
| 210 | - throw new \InvalidArgumentException('The given subject is invalid'); |
|
| 211 | - } |
|
| 212 | - $this->subject = $subject; |
|
| 213 | - $this->subjectParameters = $parameters; |
|
| 214 | - return $this; |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * @return string |
|
| 219 | - */ |
|
| 220 | - public function getSubject(): string { |
|
| 221 | - return $this->subject; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * @return array |
|
| 226 | - */ |
|
| 227 | - public function getSubjectParameters(): array { |
|
| 228 | - return $this->subjectParameters; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * @param string $subject |
|
| 233 | - * @return $this |
|
| 234 | - * @throws \InvalidArgumentException if the subject is invalid |
|
| 235 | - * @since 11.0.0 |
|
| 236 | - */ |
|
| 237 | - public function setParsedSubject(string $subject): IEvent { |
|
| 238 | - if ($subject === '') { |
|
| 239 | - throw new \InvalidArgumentException('The given parsed subject is invalid'); |
|
| 240 | - } |
|
| 241 | - $this->subjectParsed = $subject; |
|
| 242 | - return $this; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * @return string |
|
| 247 | - * @since 11.0.0 |
|
| 248 | - */ |
|
| 249 | - public function getParsedSubject(): string { |
|
| 250 | - return $this->subjectParsed; |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * @param string $subject |
|
| 255 | - * @param array $parameters |
|
| 256 | - * @return $this |
|
| 257 | - * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 258 | - * @since 11.0.0 |
|
| 259 | - */ |
|
| 260 | - public function setRichSubject(string $subject, array $parameters = []): IEvent { |
|
| 261 | - if ($subject === '') { |
|
| 262 | - throw new \InvalidArgumentException('The given parsed subject is invalid'); |
|
| 263 | - } |
|
| 264 | - $this->subjectRich = $subject; |
|
| 265 | - $this->subjectRichParameters = $parameters; |
|
| 266 | - |
|
| 267 | - return $this; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * @return string |
|
| 272 | - * @since 11.0.0 |
|
| 273 | - */ |
|
| 274 | - public function getRichSubject(): string { |
|
| 275 | - return $this->subjectRich; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * @return array[] |
|
| 280 | - * @since 11.0.0 |
|
| 281 | - */ |
|
| 282 | - public function getRichSubjectParameters(): array { |
|
| 283 | - return $this->subjectRichParameters; |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * Set the message of the activity |
|
| 288 | - * |
|
| 289 | - * @param string $message |
|
| 290 | - * @param array $parameters |
|
| 291 | - * @return IEvent |
|
| 292 | - * @throws \InvalidArgumentException if the message or parameters are invalid |
|
| 293 | - * @since 8.2.0 |
|
| 294 | - */ |
|
| 295 | - public function setMessage(string $message, array $parameters = []): IEvent { |
|
| 296 | - if (isset($message[255])) { |
|
| 297 | - throw new \InvalidArgumentException('The given message is invalid'); |
|
| 298 | - } |
|
| 299 | - $this->message = $message; |
|
| 300 | - $this->messageParameters = $parameters; |
|
| 301 | - return $this; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * @return string |
|
| 306 | - */ |
|
| 307 | - public function getMessage(): string { |
|
| 308 | - return $this->message; |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * @return array |
|
| 313 | - */ |
|
| 314 | - public function getMessageParameters(): array { |
|
| 315 | - return $this->messageParameters; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - /** |
|
| 319 | - * @param string $message |
|
| 320 | - * @return $this |
|
| 321 | - * @throws \InvalidArgumentException if the message is invalid |
|
| 322 | - * @since 11.0.0 |
|
| 323 | - */ |
|
| 324 | - public function setParsedMessage(string $message): IEvent { |
|
| 325 | - $this->messageParsed = $message; |
|
| 326 | - return $this; |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * @return string |
|
| 331 | - * @since 11.0.0 |
|
| 332 | - */ |
|
| 333 | - public function getParsedMessage(): string { |
|
| 334 | - return $this->messageParsed; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - /** |
|
| 338 | - * @param string $message |
|
| 339 | - * @param array $parameters |
|
| 340 | - * @return $this |
|
| 341 | - * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 342 | - * @since 11.0.0 |
|
| 343 | - */ |
|
| 344 | - public function setRichMessage(string $message, array $parameters = []): IEvent { |
|
| 345 | - $this->messageRich = $message; |
|
| 346 | - $this->messageRichParameters = $parameters; |
|
| 347 | - |
|
| 348 | - return $this; |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * @return string |
|
| 353 | - * @since 11.0.0 |
|
| 354 | - */ |
|
| 355 | - public function getRichMessage(): string { |
|
| 356 | - return $this->messageRich; |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * @return array[] |
|
| 361 | - * @since 11.0.0 |
|
| 362 | - */ |
|
| 363 | - public function getRichMessageParameters(): array { |
|
| 364 | - return $this->messageRichParameters; |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * Set the object of the activity |
|
| 369 | - * |
|
| 370 | - * @param string $objectType |
|
| 371 | - * @param int $objectId |
|
| 372 | - * @param string $objectName |
|
| 373 | - * @return IEvent |
|
| 374 | - * @throws \InvalidArgumentException if the object is invalid |
|
| 375 | - * @since 8.2.0 |
|
| 376 | - */ |
|
| 377 | - public function setObject(string $objectType, int $objectId, string $objectName = ''): IEvent { |
|
| 378 | - if (isset($objectType[255])) { |
|
| 379 | - throw new \InvalidArgumentException('The given object type is invalid'); |
|
| 380 | - } |
|
| 381 | - if (isset($objectName[4000])) { |
|
| 382 | - throw new \InvalidArgumentException('The given object name is invalid'); |
|
| 383 | - } |
|
| 384 | - $this->objectType = $objectType; |
|
| 385 | - $this->objectId = $objectId; |
|
| 386 | - $this->objectName = $objectName; |
|
| 387 | - return $this; |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * @return string |
|
| 392 | - */ |
|
| 393 | - public function getObjectType(): string { |
|
| 394 | - return $this->objectType; |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - /** |
|
| 398 | - * @return int |
|
| 399 | - */ |
|
| 400 | - public function getObjectId(): int { |
|
| 401 | - return $this->objectId; |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - /** |
|
| 405 | - * @return string |
|
| 406 | - */ |
|
| 407 | - public function getObjectName(): string { |
|
| 408 | - return $this->objectName; |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * Set the link of the activity |
|
| 413 | - * |
|
| 414 | - * @param string $link |
|
| 415 | - * @return IEvent |
|
| 416 | - * @throws \InvalidArgumentException if the link is invalid |
|
| 417 | - * @since 8.2.0 |
|
| 418 | - */ |
|
| 419 | - public function setLink(string $link): IEvent { |
|
| 420 | - if (isset($link[4000])) { |
|
| 421 | - throw new \InvalidArgumentException('The given link is invalid'); |
|
| 422 | - } |
|
| 423 | - $this->link = $link; |
|
| 424 | - return $this; |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - /** |
|
| 428 | - * @return string |
|
| 429 | - */ |
|
| 430 | - public function getLink(): string { |
|
| 431 | - return $this->link; |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - /** |
|
| 435 | - * @param string $icon |
|
| 436 | - * @return $this |
|
| 437 | - * @throws \InvalidArgumentException if the icon is invalid |
|
| 438 | - * @since 11.0.0 |
|
| 439 | - */ |
|
| 440 | - public function setIcon(string $icon): IEvent { |
|
| 441 | - if (isset($icon[4000])) { |
|
| 442 | - throw new \InvalidArgumentException('The given icon is invalid'); |
|
| 443 | - } |
|
| 444 | - $this->icon = $icon; |
|
| 445 | - return $this; |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - /** |
|
| 449 | - * @return string |
|
| 450 | - * @since 11.0.0 |
|
| 451 | - */ |
|
| 452 | - public function getIcon(): string { |
|
| 453 | - return $this->icon; |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * @param IEvent $child |
|
| 458 | - * @return $this |
|
| 459 | - * @since 11.0.0 - Since 15.0.0 returns $this |
|
| 460 | - */ |
|
| 461 | - public function setChildEvent(IEvent $child): IEvent { |
|
| 462 | - $this->child = $child; |
|
| 463 | - return $this; |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - /** |
|
| 467 | - * @return IEvent|null |
|
| 468 | - * @since 11.0.0 |
|
| 469 | - */ |
|
| 470 | - public function getChildEvent() { |
|
| 471 | - return $this->child; |
|
| 472 | - } |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * @return bool |
|
| 476 | - * @since 8.2.0 |
|
| 477 | - */ |
|
| 478 | - public function isValid(): bool { |
|
| 479 | - return |
|
| 480 | - $this->isValidCommon() |
|
| 481 | - && |
|
| 482 | - $this->getSubject() !== '' |
|
| 483 | - ; |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - /** |
|
| 487 | - * @return bool |
|
| 488 | - * @since 8.2.0 |
|
| 489 | - */ |
|
| 490 | - public function isValidParsed(): bool { |
|
| 491 | - if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) { |
|
| 492 | - try { |
|
| 493 | - $this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters()); |
|
| 494 | - } catch (InvalidObjectExeption $e) { |
|
| 495 | - return false; |
|
| 496 | - } |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) { |
|
| 500 | - try { |
|
| 501 | - $this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters()); |
|
| 502 | - } catch (InvalidObjectExeption $e) { |
|
| 503 | - return false; |
|
| 504 | - } |
|
| 505 | - } |
|
| 506 | - |
|
| 507 | - return |
|
| 508 | - $this->isValidCommon() |
|
| 509 | - && |
|
| 510 | - $this->getParsedSubject() !== '' |
|
| 511 | - ; |
|
| 512 | - } |
|
| 513 | - |
|
| 514 | - protected function isValidCommon(): bool { |
|
| 515 | - return |
|
| 516 | - $this->getApp() !== '' |
|
| 517 | - && |
|
| 518 | - $this->getType() !== '' |
|
| 519 | - && |
|
| 520 | - $this->getAffectedUser() !== '' |
|
| 521 | - && |
|
| 522 | - $this->getTimestamp() !== 0 |
|
| 523 | - /** |
|
| 524 | - * Disabled for BC with old activities |
|
| 34 | + /** @var string */ |
|
| 35 | + protected $app = ''; |
|
| 36 | + /** @var string */ |
|
| 37 | + protected $type = ''; |
|
| 38 | + /** @var string */ |
|
| 39 | + protected $affectedUser = ''; |
|
| 40 | + /** @var string */ |
|
| 41 | + protected $author = ''; |
|
| 42 | + /** @var int */ |
|
| 43 | + protected $timestamp = 0; |
|
| 44 | + /** @var string */ |
|
| 45 | + protected $subject = ''; |
|
| 46 | + /** @var array */ |
|
| 47 | + protected $subjectParameters = []; |
|
| 48 | + /** @var string */ |
|
| 49 | + protected $subjectParsed; |
|
| 50 | + /** @var string */ |
|
| 51 | + protected $subjectRich; |
|
| 52 | + /** @var array */ |
|
| 53 | + protected $subjectRichParameters; |
|
| 54 | + /** @var string */ |
|
| 55 | + protected $message = ''; |
|
| 56 | + /** @var array */ |
|
| 57 | + protected $messageParameters = []; |
|
| 58 | + /** @var string */ |
|
| 59 | + protected $messageParsed; |
|
| 60 | + /** @var string */ |
|
| 61 | + protected $messageRich; |
|
| 62 | + /** @var array */ |
|
| 63 | + protected $messageRichParameters; |
|
| 64 | + /** @var string */ |
|
| 65 | + protected $objectType = ''; |
|
| 66 | + /** @var int */ |
|
| 67 | + protected $objectId = 0; |
|
| 68 | + /** @var string */ |
|
| 69 | + protected $objectName = ''; |
|
| 70 | + /** @var string */ |
|
| 71 | + protected $link = ''; |
|
| 72 | + /** @var string */ |
|
| 73 | + protected $icon = ''; |
|
| 74 | + |
|
| 75 | + /** @var IEvent|null */ |
|
| 76 | + protected $child; |
|
| 77 | + /** @var IValidator */ |
|
| 78 | + protected $richValidator; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @param IValidator $richValidator |
|
| 82 | + */ |
|
| 83 | + public function __construct(IValidator $richValidator) { |
|
| 84 | + $this->richValidator = $richValidator; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Set the app of the activity |
|
| 89 | + * |
|
| 90 | + * @param string $app |
|
| 91 | + * @return IEvent |
|
| 92 | + * @throws \InvalidArgumentException if the app id is invalid |
|
| 93 | + * @since 8.2.0 |
|
| 94 | + */ |
|
| 95 | + public function setApp(string $app): IEvent { |
|
| 96 | + if ($app === '' || isset($app[32])) { |
|
| 97 | + throw new \InvalidArgumentException('The given app is invalid'); |
|
| 98 | + } |
|
| 99 | + $this->app = $app; |
|
| 100 | + return $this; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @return string |
|
| 105 | + */ |
|
| 106 | + public function getApp(): string { |
|
| 107 | + return $this->app; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Set the type of the activity |
|
| 112 | + * |
|
| 113 | + * @param string $type |
|
| 114 | + * @return IEvent |
|
| 115 | + * @throws \InvalidArgumentException if the type is invalid |
|
| 116 | + * @since 8.2.0 |
|
| 117 | + */ |
|
| 118 | + public function setType(string $type): IEvent { |
|
| 119 | + if ($type === '' || isset($type[255])) { |
|
| 120 | + throw new \InvalidArgumentException('The given type is invalid'); |
|
| 121 | + } |
|
| 122 | + $this->type = $type; |
|
| 123 | + return $this; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * @return string |
|
| 128 | + */ |
|
| 129 | + public function getType(): string { |
|
| 130 | + return $this->type; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Set the affected user of the activity |
|
| 135 | + * |
|
| 136 | + * @param string $affectedUser |
|
| 137 | + * @return IEvent |
|
| 138 | + * @throws \InvalidArgumentException if the affected user is invalid |
|
| 139 | + * @since 8.2.0 |
|
| 140 | + */ |
|
| 141 | + public function setAffectedUser(string $affectedUser): IEvent { |
|
| 142 | + if ($affectedUser === '' || isset($affectedUser[64])) { |
|
| 143 | + throw new \InvalidArgumentException('The given affected user is invalid'); |
|
| 144 | + } |
|
| 145 | + $this->affectedUser = $affectedUser; |
|
| 146 | + return $this; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * @return string |
|
| 151 | + */ |
|
| 152 | + public function getAffectedUser(): string { |
|
| 153 | + return $this->affectedUser; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Set the author of the activity |
|
| 158 | + * |
|
| 159 | + * @param string $author |
|
| 160 | + * @return IEvent |
|
| 161 | + * @throws \InvalidArgumentException if the author is invalid |
|
| 162 | + * @since 8.2.0 |
|
| 163 | + */ |
|
| 164 | + public function setAuthor(string $author): IEvent { |
|
| 165 | + if (isset($author[64])) { |
|
| 166 | + throw new \InvalidArgumentException('The given author user is invalid'); |
|
| 167 | + } |
|
| 168 | + $this->author = $author; |
|
| 169 | + return $this; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * @return string |
|
| 174 | + */ |
|
| 175 | + public function getAuthor(): string { |
|
| 176 | + return $this->author; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * Set the timestamp of the activity |
|
| 181 | + * |
|
| 182 | + * @param int $timestamp |
|
| 183 | + * @return IEvent |
|
| 184 | + * @throws \InvalidArgumentException if the timestamp is invalid |
|
| 185 | + * @since 8.2.0 |
|
| 186 | + */ |
|
| 187 | + public function setTimestamp(int $timestamp): IEvent { |
|
| 188 | + $this->timestamp = $timestamp; |
|
| 189 | + return $this; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * @return int |
|
| 194 | + */ |
|
| 195 | + public function getTimestamp(): int { |
|
| 196 | + return $this->timestamp; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * Set the subject of the activity |
|
| 201 | + * |
|
| 202 | + * @param string $subject |
|
| 203 | + * @param array $parameters |
|
| 204 | + * @return IEvent |
|
| 205 | + * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 206 | + * @since 8.2.0 |
|
| 207 | + */ |
|
| 208 | + public function setSubject(string $subject, array $parameters = []): IEvent { |
|
| 209 | + if (isset($subject[255])) { |
|
| 210 | + throw new \InvalidArgumentException('The given subject is invalid'); |
|
| 211 | + } |
|
| 212 | + $this->subject = $subject; |
|
| 213 | + $this->subjectParameters = $parameters; |
|
| 214 | + return $this; |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * @return string |
|
| 219 | + */ |
|
| 220 | + public function getSubject(): string { |
|
| 221 | + return $this->subject; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * @return array |
|
| 226 | + */ |
|
| 227 | + public function getSubjectParameters(): array { |
|
| 228 | + return $this->subjectParameters; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * @param string $subject |
|
| 233 | + * @return $this |
|
| 234 | + * @throws \InvalidArgumentException if the subject is invalid |
|
| 235 | + * @since 11.0.0 |
|
| 236 | + */ |
|
| 237 | + public function setParsedSubject(string $subject): IEvent { |
|
| 238 | + if ($subject === '') { |
|
| 239 | + throw new \InvalidArgumentException('The given parsed subject is invalid'); |
|
| 240 | + } |
|
| 241 | + $this->subjectParsed = $subject; |
|
| 242 | + return $this; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * @return string |
|
| 247 | + * @since 11.0.0 |
|
| 248 | + */ |
|
| 249 | + public function getParsedSubject(): string { |
|
| 250 | + return $this->subjectParsed; |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * @param string $subject |
|
| 255 | + * @param array $parameters |
|
| 256 | + * @return $this |
|
| 257 | + * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 258 | + * @since 11.0.0 |
|
| 259 | + */ |
|
| 260 | + public function setRichSubject(string $subject, array $parameters = []): IEvent { |
|
| 261 | + if ($subject === '') { |
|
| 262 | + throw new \InvalidArgumentException('The given parsed subject is invalid'); |
|
| 263 | + } |
|
| 264 | + $this->subjectRich = $subject; |
|
| 265 | + $this->subjectRichParameters = $parameters; |
|
| 266 | + |
|
| 267 | + return $this; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * @return string |
|
| 272 | + * @since 11.0.0 |
|
| 273 | + */ |
|
| 274 | + public function getRichSubject(): string { |
|
| 275 | + return $this->subjectRich; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * @return array[] |
|
| 280 | + * @since 11.0.0 |
|
| 281 | + */ |
|
| 282 | + public function getRichSubjectParameters(): array { |
|
| 283 | + return $this->subjectRichParameters; |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * Set the message of the activity |
|
| 288 | + * |
|
| 289 | + * @param string $message |
|
| 290 | + * @param array $parameters |
|
| 291 | + * @return IEvent |
|
| 292 | + * @throws \InvalidArgumentException if the message or parameters are invalid |
|
| 293 | + * @since 8.2.0 |
|
| 294 | + */ |
|
| 295 | + public function setMessage(string $message, array $parameters = []): IEvent { |
|
| 296 | + if (isset($message[255])) { |
|
| 297 | + throw new \InvalidArgumentException('The given message is invalid'); |
|
| 298 | + } |
|
| 299 | + $this->message = $message; |
|
| 300 | + $this->messageParameters = $parameters; |
|
| 301 | + return $this; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * @return string |
|
| 306 | + */ |
|
| 307 | + public function getMessage(): string { |
|
| 308 | + return $this->message; |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * @return array |
|
| 313 | + */ |
|
| 314 | + public function getMessageParameters(): array { |
|
| 315 | + return $this->messageParameters; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + /** |
|
| 319 | + * @param string $message |
|
| 320 | + * @return $this |
|
| 321 | + * @throws \InvalidArgumentException if the message is invalid |
|
| 322 | + * @since 11.0.0 |
|
| 323 | + */ |
|
| 324 | + public function setParsedMessage(string $message): IEvent { |
|
| 325 | + $this->messageParsed = $message; |
|
| 326 | + return $this; |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * @return string |
|
| 331 | + * @since 11.0.0 |
|
| 332 | + */ |
|
| 333 | + public function getParsedMessage(): string { |
|
| 334 | + return $this->messageParsed; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * @param string $message |
|
| 339 | + * @param array $parameters |
|
| 340 | + * @return $this |
|
| 341 | + * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 342 | + * @since 11.0.0 |
|
| 343 | + */ |
|
| 344 | + public function setRichMessage(string $message, array $parameters = []): IEvent { |
|
| 345 | + $this->messageRich = $message; |
|
| 346 | + $this->messageRichParameters = $parameters; |
|
| 347 | + |
|
| 348 | + return $this; |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * @return string |
|
| 353 | + * @since 11.0.0 |
|
| 354 | + */ |
|
| 355 | + public function getRichMessage(): string { |
|
| 356 | + return $this->messageRich; |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * @return array[] |
|
| 361 | + * @since 11.0.0 |
|
| 362 | + */ |
|
| 363 | + public function getRichMessageParameters(): array { |
|
| 364 | + return $this->messageRichParameters; |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * Set the object of the activity |
|
| 369 | + * |
|
| 370 | + * @param string $objectType |
|
| 371 | + * @param int $objectId |
|
| 372 | + * @param string $objectName |
|
| 373 | + * @return IEvent |
|
| 374 | + * @throws \InvalidArgumentException if the object is invalid |
|
| 375 | + * @since 8.2.0 |
|
| 376 | + */ |
|
| 377 | + public function setObject(string $objectType, int $objectId, string $objectName = ''): IEvent { |
|
| 378 | + if (isset($objectType[255])) { |
|
| 379 | + throw new \InvalidArgumentException('The given object type is invalid'); |
|
| 380 | + } |
|
| 381 | + if (isset($objectName[4000])) { |
|
| 382 | + throw new \InvalidArgumentException('The given object name is invalid'); |
|
| 383 | + } |
|
| 384 | + $this->objectType = $objectType; |
|
| 385 | + $this->objectId = $objectId; |
|
| 386 | + $this->objectName = $objectName; |
|
| 387 | + return $this; |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * @return string |
|
| 392 | + */ |
|
| 393 | + public function getObjectType(): string { |
|
| 394 | + return $this->objectType; |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + /** |
|
| 398 | + * @return int |
|
| 399 | + */ |
|
| 400 | + public function getObjectId(): int { |
|
| 401 | + return $this->objectId; |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + /** |
|
| 405 | + * @return string |
|
| 406 | + */ |
|
| 407 | + public function getObjectName(): string { |
|
| 408 | + return $this->objectName; |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * Set the link of the activity |
|
| 413 | + * |
|
| 414 | + * @param string $link |
|
| 415 | + * @return IEvent |
|
| 416 | + * @throws \InvalidArgumentException if the link is invalid |
|
| 417 | + * @since 8.2.0 |
|
| 418 | + */ |
|
| 419 | + public function setLink(string $link): IEvent { |
|
| 420 | + if (isset($link[4000])) { |
|
| 421 | + throw new \InvalidArgumentException('The given link is invalid'); |
|
| 422 | + } |
|
| 423 | + $this->link = $link; |
|
| 424 | + return $this; |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + /** |
|
| 428 | + * @return string |
|
| 429 | + */ |
|
| 430 | + public function getLink(): string { |
|
| 431 | + return $this->link; |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + /** |
|
| 435 | + * @param string $icon |
|
| 436 | + * @return $this |
|
| 437 | + * @throws \InvalidArgumentException if the icon is invalid |
|
| 438 | + * @since 11.0.0 |
|
| 439 | + */ |
|
| 440 | + public function setIcon(string $icon): IEvent { |
|
| 441 | + if (isset($icon[4000])) { |
|
| 442 | + throw new \InvalidArgumentException('The given icon is invalid'); |
|
| 443 | + } |
|
| 444 | + $this->icon = $icon; |
|
| 445 | + return $this; |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + /** |
|
| 449 | + * @return string |
|
| 450 | + * @since 11.0.0 |
|
| 451 | + */ |
|
| 452 | + public function getIcon(): string { |
|
| 453 | + return $this->icon; |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * @param IEvent $child |
|
| 458 | + * @return $this |
|
| 459 | + * @since 11.0.0 - Since 15.0.0 returns $this |
|
| 460 | + */ |
|
| 461 | + public function setChildEvent(IEvent $child): IEvent { |
|
| 462 | + $this->child = $child; |
|
| 463 | + return $this; |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + /** |
|
| 467 | + * @return IEvent|null |
|
| 468 | + * @since 11.0.0 |
|
| 469 | + */ |
|
| 470 | + public function getChildEvent() { |
|
| 471 | + return $this->child; |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * @return bool |
|
| 476 | + * @since 8.2.0 |
|
| 477 | + */ |
|
| 478 | + public function isValid(): bool { |
|
| 479 | + return |
|
| 480 | + $this->isValidCommon() |
|
| 481 | + && |
|
| 482 | + $this->getSubject() !== '' |
|
| 483 | + ; |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + /** |
|
| 487 | + * @return bool |
|
| 488 | + * @since 8.2.0 |
|
| 489 | + */ |
|
| 490 | + public function isValidParsed(): bool { |
|
| 491 | + if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) { |
|
| 492 | + try { |
|
| 493 | + $this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters()); |
|
| 494 | + } catch (InvalidObjectExeption $e) { |
|
| 495 | + return false; |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) { |
|
| 500 | + try { |
|
| 501 | + $this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters()); |
|
| 502 | + } catch (InvalidObjectExeption $e) { |
|
| 503 | + return false; |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + return |
|
| 508 | + $this->isValidCommon() |
|
| 509 | + && |
|
| 510 | + $this->getParsedSubject() !== '' |
|
| 511 | + ; |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + protected function isValidCommon(): bool { |
|
| 515 | + return |
|
| 516 | + $this->getApp() !== '' |
|
| 517 | + && |
|
| 518 | + $this->getType() !== '' |
|
| 519 | + && |
|
| 520 | + $this->getAffectedUser() !== '' |
|
| 521 | + && |
|
| 522 | + $this->getTimestamp() !== 0 |
|
| 523 | + /** |
|
| 524 | + * Disabled for BC with old activities |
|
| 525 | 525 | && |
| 526 | 526 | $this->getObjectType() !== '' |
| 527 | 527 | && |
| 528 | 528 | $this->getObjectId() !== 0 |
| 529 | - */ |
|
| 530 | - ; |
|
| 531 | - } |
|
| 529 | + */ |
|
| 530 | + ; |
|
| 531 | + } |
|
| 532 | 532 | } |