From 3da01bf1e34c537316f5ccf9844773b7122dc126 Mon Sep 17 00:00:00 2001 From: Flemming Andersen Date: Sat, 17 Aug 2013 19:45:33 +0200 Subject: [PATCH] Made email receiver configurable --- config/flamingsms.global.php.dist | 6 +++++- config/module.config.php | 4 ++++ src/FlamingSms/Cli/SmsQueueController.php | 15 +++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/config/flamingsms.global.php.dist b/config/flamingsms.global.php.dist index 3376df6..009416a 100644 --- a/config/flamingsms.global.php.dist +++ b/config/flamingsms.global.php.dist @@ -13,6 +13,10 @@ return array( 'gateway_classmap' => array( 'coolsms' => 'FlamingSms\SmsGateway\CoolSms', 'fakegw' => 'FlamingSms\SmsGateway\FakeGw', - ) + ), + + 'sms_queue' => array( + 'default_email_receiver' => 'my-receiver@email.invalid' + ), ) ); \ No newline at end of file diff --git a/config/module.config.php b/config/module.config.php index 6162a8c..02d8541 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -113,6 +113,10 @@ 'coolsms' => 'FlamingSms\SmsGateway\CoolSms', 'fakegw' => 'FlamingSms\SmsGateway\FakeGw', ), + + 'sms_queue' => array( + 'default_email_receiver' => 'my-receiver@email.invalid' + ), 'gateway_config' => array( 'coolsms' => array( diff --git a/src/FlamingSms/Cli/SmsQueueController.php b/src/FlamingSms/Cli/SmsQueueController.php index 4ac9f72..096d334 100644 --- a/src/FlamingSms/Cli/SmsQueueController.php +++ b/src/FlamingSms/Cli/SmsQueueController.php @@ -33,6 +33,8 @@ class SmsQueueController extends AbstractCliController * @var SmsService */ protected $smsService; + + protected $emailReceiver; public function runAction() { @@ -97,7 +99,7 @@ protected function runRegular($limit, $gatewayName = null, $forceGateway = null, if ($sendMail && 0 < $smsCountTotal) { - $this->emailer()->sendMail('operations@quickinfo.dk', + $this->emailer()->sendMail($this->getEmailReceiver(), 'FlamingSms [' . $this->env() . '] - smsqueue run', $output); } @@ -150,7 +152,7 @@ protected function cleanSmsQueue($gatewayName = null, $sendMail = false) } if ((0 < $sentCleanupCount || 0 < $queuedCleanupCount) && $sendMail) { - $this->emailer()->sendMail('operations@quickinfo.dk', + $this->emailer()->sendMail($this->getEmailReceiver(), 'FlamingSms [' . $this->env() . '] - smsqueue clean', $output); } @@ -180,4 +182,13 @@ public function setSmsService(SmsService $smsService) $this->smsService = $smsService; return $this; } + + public function getEmailReceiver() + { + if (!$this->emailReceiver) { + $config = $this->getServiceLocator()->get('Configuration'); + $this->emailReceiver = $config['flamingsms']['sms_queue']['default_email_receiver']; + } + return $this->emailReceiver; + } } \ No newline at end of file