This is a little helper function which automatically sets the simple parsed subject based on the rich subject you set.
(INotification $notification)
| 154 | // This is a little helper function which automatically sets the simple parsed subject |
| 155 | // based on the rich subject you set. |
| 156 | protected function setParsedSubjectFromRichSubject(INotification $notification) |
| 157 | { |
| 158 | $placeholders = $replacements = []; |
| 159 | foreach ($notification->getRichSubjectParameters() as $placeholder => $parameter) { |
| 160 | $placeholders[] = '{' . $placeholder . '}'; |
| 161 | if ($parameter['type'] === 'file') { |
| 162 | $replacements[] = $parameter['path']; |
| 163 | } else { |
| 164 | $replacements[] = $parameter['name']; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | $notification->setParsedSubject(str_replace($placeholders, $replacements, $notification->getRichSubject())); |
| 169 | } |
| 170 | |
| 171 | } |