]> git.mxchange.org Git - friendica.git/commitdiff
Fix invalid "emailer_prepare" Hook
authornupplaPhil <admin@philipp.info>
Wed, 29 Jan 2020 19:20:40 +0000 (20:20 +0100)
committernupplaPhil <admin@philipp.info>
Wed, 29 Jan 2020 19:20:40 +0000 (20:20 +0100)
- Use IEmail instead of array data
- Introduce "composer" based library for phpmailer

doc/de/Addons.md
src/Object/Email.php
src/Util/Emailer.php

index aba36bbea420e7973f748b8f8a1532ff9c1429e4..b54f011bfe7d9fe7e3d90b3ab702f7dc4a0f9a5b 100644 (file)
@@ -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
index 23e1fcfcd585f702a9f05b753dcefee5df7505c7..4f9c4e7bd94164678e2ad3f63d147a1a5a1743a2 100644 (file)
@@ -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;
+       }
 }
index 8f6dc09e1614d0839734867a6e3045871d563ca9..19755bebdae594563de7be44f32fa16096116d36 100644 (file)
@@ -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;
                }