Skip to content

Commit

Permalink
Update doc to remove call to setParsedSubject
Browse files Browse the repository at this point in the history
It is now called automatically by setRichSubject

Signed-off-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
  • Loading branch information
come-nc authored Feb 21, 2023
1 parent 6046eba commit 433f394
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions docs/notification-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,31 +144,13 @@ class Notifier implements \OCP\Notification\INotifier {
$notification->addParsedAction($action);
}

// Set the plain text subject automatically
$this->setParsedSubjectFromRichSubject($notification);
return $notification;

default:
// Unknown subject => Unknown notification => throw
throw new \InvalidArgumentException();
}
}

// This is a little helper function which automatically sets the simple parsed subject
// based on the rich subject you set.
protected function setParsedSubjectFromRichSubject(INotification $notification) {
$placeholders = $replacements = [];
foreach ($notification->getRichSubjectParameters() as $placeholder => $parameter) {
$placeholders[] = '{' . $placeholder . '}';
if ($parameter['type'] === 'file') {
$replacements[] = $parameter['path'];
} else {
$replacements[] = $parameter['name'];
}
}

$notification->setParsedSubject(str_replace($placeholders, $replacements, $notification->getRichSubject()));
}
}
```

Expand Down

0 comments on commit 433f394

Please sign in to comment.