From f6aea0d65ae9cb095c1ee4f948f0c1d8f156ff66 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Wed, 29 Jan 2020 20:20:40 +0100 Subject: [PATCH] Fix invalid "emailer_prepare" Hook - Use IEmail instead of array data - Introduce "composer" based library for phpmailer --- doc/de/Addons.md | 2 +- src/Object/Email.php | 21 +++++++++++++++++++++ src/Util/Emailer.php | 6 ++---- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/doc/de/Addons.md b/doc/de/Addons.md index aba36bbea4..b54f011bfe 100644 --- a/doc/de/Addons.md +++ b/doc/de/Addons.md @@ -475,7 +475,7 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap ### src/Util/Emailer.php - Hook::callAll('emailer_send_prepare', $params); + Hook::callAll('emailer_send_prepare', $email); Hook::callAll("emailer_send", $hookdata); ### src/Util/Map.php diff --git a/src/Object/Email.php b/src/Object/Email.php index 23e1fcfcd5..4f9c4e7bd9 100644 --- a/src/Object/Email.php +++ b/src/Object/Email.php @@ -132,4 +132,25 @@ class Email implements IEmail return $newEmail; } + + /** + * Creates a new Email instance based on a given prototype + * + * @param static $prototype The base prototype + * @param array $data The delta-data (key must be an existing property) + * + * @return static The new email instance + */ + public static function createFromPrototype(Email $prototype, array $data = []) + { + $newMail = clone $prototype; + + foreach ($data as $key => $value) { + if (property_exists($newMail, $key)) { + $newMail->{$key} = $value; + } + } + + return $newMail; + } } diff --git a/src/Util/Emailer.php b/src/Util/Emailer.php index 8f6dc09e16..19755bebda 100644 --- a/src/Util/Emailer.php +++ b/src/Util/Emailer.php @@ -45,11 +45,9 @@ class Emailer */ public function send(IEmail $email) { - $params['sent'] = false; + Hook::callAll('emailer_send_prepare', $email); - Hook::callAll('emailer_send_prepare', $params); - - if ($params['sent']) { + if (empty($email)) { return true; }