summaryrefslogtreecommitdiff
path: root/app/frontend/mail/MailModule.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/frontend/mail/MailModule.php')
-rw-r--r--app/frontend/mail/MailModule.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/frontend/mail/MailModule.php b/app/frontend/mail/MailModule.php
index 5f7749b..e10c556 100644
--- a/app/frontend/mail/MailModule.php
+++ b/app/frontend/mail/MailModule.php
@@ -1,16 +1,29 @@
<?php
Prado::using('System.I18N.Globalization');
+Prado::using('Application.mail.Mailer');
Prado::using('Application.mail.MailTemplate');
Prado::using('Application.mail.MailTemplateTranslator');
class MailModule extends TModule {
+ private $_configPath;
+ private $_config;
+
private $_templatePath;
private static $_templateExtension = 'html';
private $_templateCacheSubpath = 'mail';
private static $_templateTranslationCatalogue = 'messages';
+ public function setConfigPath($configPath) {
+ $this->_configPath = TPropertyValue::ensureString($configPath);
+ $this->_config = json_decode(
+ file_get_contents(
+ Prado::getPathOfNamespace($this->_configPath, '.json')
+ )
+ );
+ }
+
public function setTemplatePath($templatePath) {
$this->_templatePath = Prado::getPathOfNamespace(
TPropertyValue::ensureString($templatePath)
@@ -90,6 +103,19 @@ class MailModule extends TModule {
return $template;
}
+ public function getMailer() {
+ if (!$this->_config) {
+ throw new TConfigurationException(
+ Prado::localize(
+ 'Mailer not configured'
+ )
+ );
+ }
+ $mailer = new Mailer();
+ $mailer->configure($this->_config);
+ return $mailer;
+ }
+
}
?>