| @@ 357-372 (lines=16) @@ | ||
| 354 | * @throws \InvalidArgumentException if the action are invalid |
|
| 355 | * @since 8.2.0 |
|
| 356 | */ |
|
| 357 | public function addAction(IAction $action) { |
|
| 358 | if (!$action->isValid()) { |
|
| 359 | throw new \InvalidArgumentException('The given action is invalid'); |
|
| 360 | } |
|
| 361 | ||
| 362 | if ($action->isPrimary()) { |
|
| 363 | if ($this->hasPrimaryAction) { |
|
| 364 | throw new \InvalidArgumentException('The notification already has a primary action'); |
|
| 365 | } |
|
| 366 | ||
| 367 | $this->hasPrimaryAction = true; |
|
| 368 | } |
|
| 369 | ||
| 370 | $this->actions[] = $action; |
|
| 371 | return $this; |
|
| 372 | } |
|
| 373 | ||
| 374 | /** |
|
| 375 | * @return IAction[] |
|
| @@ 388-403 (lines=16) @@ | ||
| 385 | * @throws \InvalidArgumentException if the action are invalid |
|
| 386 | * @since 8.2.0 |
|
| 387 | */ |
|
| 388 | public function addParsedAction(IAction $action) { |
|
| 389 | if (!$action->isValidParsed()) { |
|
| 390 | throw new \InvalidArgumentException('The given parsed action is invalid'); |
|
| 391 | } |
|
| 392 | ||
| 393 | if ($action->isPrimary()) { |
|
| 394 | if ($this->hasPrimaryParsedAction) { |
|
| 395 | throw new \InvalidArgumentException('The notification already has a primary action'); |
|
| 396 | } |
|
| 397 | ||
| 398 | $this->hasPrimaryParsedAction = true; |
|
| 399 | } |
|
| 400 | ||
| 401 | $this->actionsParsed[] = $action; |
|
| 402 | return $this; |
|
| 403 | } |
|
| 404 | ||
| 405 | /** |
|
| 406 | * @return IAction[] |
|