- Use IEmail instead of array data
- Introduce "composer" based library for phpmailer
### 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
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;
+ }
}
*/
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;
}