From f109c1a10c9f5acf0d5d3e4f864e3702f99db937 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 15 Sep 2017 10:51:55 +0200 Subject: Allow templating of email subjects Signed-off-by: Joas Schilling --- lib/private/Mail/EMailTemplate.php | 20 ++++++++++++++++++++ lib/public/Mail/IEMailTemplate.php | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php index da3341b6709..e4e28a9294e 100644 --- a/lib/private/Mail/EMailTemplate.php +++ b/lib/private/Mail/EMailTemplate.php @@ -50,6 +50,8 @@ class EMailTemplate implements IEMailTemplate { /** @var array */ protected $data; + /** @var string */ + protected $subject = ''; /** @var string */ protected $htmlBody = ''; /** @var string */ @@ -358,6 +360,15 @@ EOF; $this->data = $data; } + /** + * Sets the subject of the email + * + * @param string $subject + */ + public function setSubject($subject) { + $this->subject = $subject; + } + /** * Adds a header to the email */ @@ -595,6 +606,15 @@ EOF; $this->plainBody .= str_replace('
', PHP_EOL, $text); } + /** + * Returns the rendered email subject as string + * + * @return string + */ + public function renderSubject() { + return $this->subject; + } + /** * Returns the rendered HTML email as string * diff --git a/lib/public/Mail/IEMailTemplate.php b/lib/public/Mail/IEMailTemplate.php index 04a3905c2e3..c1766076c44 100644 --- a/lib/public/Mail/IEMailTemplate.php +++ b/lib/public/Mail/IEMailTemplate.php @@ -52,6 +52,15 @@ namespace OCP\Mail; */ interface IEMailTemplate { + /** + * Sets the subject of the email + * + * @param string $subject + * + * @since 13.0.0 + */ + public function setSubject($subject); + /** * Adds a header to the email * @@ -130,6 +139,15 @@ interface IEMailTemplate { */ public function addFooter($text = ''); + /** + * Returns the rendered email subject as string + * + * @return string + * + * @since 13.0.0 + */ + public function renderSubject(); + /** * Returns the rendered HTML email as string * -- cgit v1.2.3