Skip to content
Browse files

UPDATED: 3.1 compatibility

ADDED: Extension hook for updating email object prior to send
UPDATED: Documentation
  • Loading branch information...
1 parent 59fd941 commit 1685ee2070ceaf94bea49031e0a946aef5feb567 @tractorcow committed
View
15 README.md
@@ -37,6 +37,21 @@ CommentsNotifications:
recipient: 'Page'
```
+## Extending
+
+To hook into the outgoing email (in order to customise the template) you can
+extend CommentingController with an extending class with a function updateEmail
+
+```php
+class EmailSenderExtension extends Extension {
+ public function updateEmail(Email &$email) {
+ $email->populateTemplate(array(
+ 'SiteConfig' => SiteConfig::current_site_config()
+ ));
+ }
+}
+```
+
## Need more help?
Message or email me at damian.mooyman@gmail.com or, well, read the code!
View
2 code/CommentsNotifications.php
@@ -31,4 +31,4 @@ public static function get_recipient($parent) {
default: return $recipient;
}
}
-}
+}
View
4 code/extensions/CommentingControllerNotificationsExtension.php
@@ -38,7 +38,9 @@ public function onAfterPostComment(Comment $comment) {
$email->addCustomHeader('X-Sender', $sender);
$email->addCustomHeader('Sender', $sender);
+ $this->owner->extend('updateEmail', $email);
+
// Send
$email->send();
}
-}
+}
View
4 code/extensions/CommentsNotificationsExtension.php
@@ -4,7 +4,7 @@
* @author Damian Mooyman
*/
class CommentsNotificationsExtension extends DataExtension {
- static $db = array(
+ private static $db = array(
'CommentNotificationEmail' => 'Varchar(255)'
);
-}
+}
View
2 code/extensions/PageCommentsNotificationsExtension.php
@@ -13,4 +13,4 @@ public function updateSettingsFields(FieldList $fields) {
);
}
}
-}
+}
View
2 code/extensions/SiteConfigCommentsNotificationsExtension.php
@@ -13,4 +13,4 @@ public function updateCMSFields(FieldList $fields) {
);
}
}
-}
+}

0 comments on commit 1685ee2

Please sign in to comment.
Something went wrong with that request. Please try again.