Skip to content
Snippets Groups Projects
Commit f270c770 authored by Demian Katz's avatar Demian Katz
Browse files

Mailer and SMS objects are now loaded through the service manager.

parent d5ce7417
Branches
Tags
No related merge requests found
...@@ -288,9 +288,11 @@ $config = array( ...@@ -288,9 +288,11 @@ $config = array(
'authmanager' => 'VuFind\Auth\Manager', 'authmanager' => 'VuFind\Auth\Manager',
'cart' => 'VuFind\Cart', 'cart' => 'VuFind\Cart',
'cachemanager' => 'VuFind\Cache\Manager', 'cachemanager' => 'VuFind\Cache\Manager',
'mailer' => 'VuFind\Mailer',
'recordloader' => 'VuFind\Record\Loader', 'recordloader' => 'VuFind\Record\Loader',
'searchspecsreader' => 'VuFind\Config\SearchSpecsReader', 'searchspecsreader' => 'VuFind\Config\SearchSpecsReader',
'sessionmanager' => 'Zend\Session\SessionManager', 'sessionmanager' => 'Zend\Session\SessionManager',
'sms' => 'VuFind\Mailer\SMS',
) )
), ),
'session_plugin_manager' => array( 'session_plugin_manager' => array(
......
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
* @link http://vufind.org/wiki/building_a_recommendations_module Wiki * @link http://vufind.org/wiki/building_a_recommendations_module Wiki
*/ */
namespace VuFind\Controller; namespace VuFind\Controller;
use VuFind\Exception\Mail as MailException, VuFind\Export, VuFind\Mailer, use VuFind\Exception\Mail as MailException, VuFind\Export,
VuFind\Mailer\SMS, VuFind\Record\Router as RecordRouter, VuFind\Record\Router as RecordRouter,
Zend\Session\Container as SessionContainer; Zend\Session\Container as SessionContainer;
/** /**
...@@ -307,8 +307,7 @@ class AbstractRecord extends AbstractBase ...@@ -307,8 +307,7 @@ class AbstractRecord extends AbstractBase
// Attempt to send the email and show an appropriate flash message: // Attempt to send the email and show an appropriate flash message:
try { try {
$mailer = new Mailer(); $this->getServiceLocator()->get('Mailer')->sendRecord(
$mailer->sendRecord(
$view->to, $view->from, $view->message, $driver, $view->to, $view->from, $view->message, $driver,
$this->getViewRenderer() $this->getViewRenderer()
); );
...@@ -337,9 +336,9 @@ class AbstractRecord extends AbstractBase ...@@ -337,9 +336,9 @@ class AbstractRecord extends AbstractBase
$driver = $this->loadRecord(); $driver = $this->loadRecord();
// Load the SMS carrier list: // Load the SMS carrier list:
$mailer = new SMS(); $sms = $this->getServiceLocator()->get('SMS');
$view = $this->createViewModel(); $view = $this->createViewModel();
$view->carriers = $mailer->getCarriers(); $view->carriers = $sms->getCarriers();
// Process form submission: // Process form submission:
if ($this->params()->fromPost('submit')) { if ($this->params()->fromPost('submit')) {
...@@ -349,7 +348,7 @@ class AbstractRecord extends AbstractBase ...@@ -349,7 +348,7 @@ class AbstractRecord extends AbstractBase
// Attempt to send the email and show an appropriate flash message: // Attempt to send the email and show an appropriate flash message:
try { try {
$mailer->textRecord( $sms->textRecord(
$view->provider, $view->to, $driver, $this->getViewRenderer() $view->provider, $view->to, $driver, $this->getViewRenderer()
); );
$this->flashMessenger()->setNamespace('info') $this->flashMessenger()->setNamespace('info')
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
namespace VuFind\Controller; namespace VuFind\Controller;
use VuFind\Config\Reader as ConfigReader, use VuFind\Config\Reader as ConfigReader,
VuFind\Connection\Manager as ConnectionManager, VuFind\Connection\Manager as ConnectionManager,
VuFind\Exception\Auth as AuthException, VuFind\Export, VuFind\Mailer, VuFind\Exception\Auth as AuthException, VuFind\Export,
VuFind\Mailer\SMS, VuFind\Translator\Translator; VuFind\Translator\Translator;
/** /**
* This controller handles global AJAX functionality * This controller handles global AJAX functionality
...@@ -940,8 +940,7 @@ class AjaxController extends AbstractBase ...@@ -940,8 +940,7 @@ class AjaxController extends AbstractBase
$this->params()->fromPost('id'), $this->params()->fromPost('id'),
$this->params()->fromPost('source', 'VuFind') $this->params()->fromPost('source', 'VuFind')
); );
$mailer = new SMS(); $this->getServiceLocator()->get('SMS')->textRecord(
$mailer->textRecord(
$this->params()->fromPost('provider'), $this->params()->fromPost('provider'),
$this->params()->fromPost('to'), $record, $this->getViewRenderer() $this->params()->fromPost('to'), $record, $this->getViewRenderer()
); );
...@@ -969,8 +968,7 @@ class AjaxController extends AbstractBase ...@@ -969,8 +968,7 @@ class AjaxController extends AbstractBase
$this->params()->fromPost('id'), $this->params()->fromPost('id'),
$this->params()->fromPost('source', 'VuFind') $this->params()->fromPost('source', 'VuFind')
); );
$mailer = new Mailer(); $this->getServiceLocator()->get('Mailer')->sendRecord(
$mailer->sendRecord(
$this->params()->fromPost('to'), $this->params()->fromPost('from'), $this->params()->fromPost('to'), $this->params()->fromPost('from'),
$this->params()->fromPost('message'), $record, $this->params()->fromPost('message'), $record,
$this->getViewRenderer() $this->getViewRenderer()
...@@ -1002,8 +1000,7 @@ class AjaxController extends AbstractBase ...@@ -1002,8 +1000,7 @@ class AjaxController extends AbstractBase
// Attempt to send the email: // Attempt to send the email:
try { try {
$mailer = new Mailer(); $this->getServiceLocator()->get('Mailer')->sendLink(
$mailer->sendLink(
$this->params()->fromPost('to'), $this->params()->fromPost('from'), $this->params()->fromPost('to'), $this->params()->fromPost('from'),
$this->params()->fromPost('message'), $this->params()->fromPost('message'),
$url, $this->getViewRenderer(), $this->params()->fromPost('subject') $url, $this->getViewRenderer(), $this->params()->fromPost('subject')
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* @link http://vufind.org Main Site * @link http://vufind.org Main Site
*/ */
namespace VuFind\Controller; namespace VuFind\Controller;
use VuFind\Exception\Mail as MailException, VuFind\Export, VuFind\Mailer, use VuFind\Exception\Mail as MailException, VuFind\Export,
VuFind\Translator\Translator, Zend\Session\Container as SessionContainer; VuFind\Translator\Translator, Zend\Session\Container as SessionContainer;
/** /**
...@@ -192,8 +192,7 @@ class CartController extends AbstractBase ...@@ -192,8 +192,7 @@ class CartController extends AbstractBase
// Attempt to send the email and show an appropriate flash message: // Attempt to send the email and show an appropriate flash message:
try { try {
// If we got this far, we're ready to send the email: // If we got this far, we're ready to send the email:
$mailer = new Mailer(); $this->getServiceLocator()->get('Mailer')->sendLink(
$mailer->sendLink(
$view->to, $view->from, $view->message, $view->to, $view->from, $view->message,
$url, $this->getViewRenderer(), 'bulk_email_title' $url, $this->getViewRenderer(), 'bulk_email_title'
); );
......
...@@ -29,7 +29,7 @@ namespace VuFind\Controller; ...@@ -29,7 +29,7 @@ namespace VuFind\Controller;
use VuFind\Config\Reader as ConfigReader, use VuFind\Config\Reader as ConfigReader,
VuFind\Connection\Manager as ConnectionManager, VuFind\Connection\Manager as ConnectionManager,
VuFind\Exception\Mail as MailException, VuFind\Mailer, VuFind\Search\Memory, VuFind\Exception\Mail as MailException, VuFind\Search\Memory,
VuFind\Solr\Utils as SolrUtils; VuFind\Solr\Utils as SolrUtils;
/** /**
...@@ -100,8 +100,7 @@ class SearchController extends AbstractSearch ...@@ -100,8 +100,7 @@ class SearchController extends AbstractSearch
// Attempt to send the email and show an appropriate flash message: // Attempt to send the email and show an appropriate flash message:
try { try {
// If we got this far, we're ready to send the email: // If we got this far, we're ready to send the email:
$mailer = new Mailer(); $this->getServiceLocator()->get('Mailer')->sendLink(
$mailer->sendLink(
$view->to, $view->from, $view->message, $view->to, $view->from, $view->message,
$view->url, $this->getViewRenderer() $view->url, $this->getViewRenderer()
); );
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
* @link http://vufind.org Main Site * @link http://vufind.org Main Site
*/ */
namespace VuFind\Log; namespace VuFind\Log;
use VuFind\Mailer, use Zend\Db\TableGateway\Feature\GlobalAdapterFeature as DbGlobalAdapter,
Zend\Db\TableGateway\Feature\GlobalAdapterFeature as DbGlobalAdapter,
Zend\Log\Logger as BaseLogger, Zend\Log\Logger as BaseLogger,
Zend\ServiceManager\ServiceLocatorAwareInterface, Zend\ServiceManager\ServiceLocatorAwareInterface,
Zend\ServiceManager\ServiceLocatorInterface; Zend\ServiceManager\ServiceLocatorInterface;
...@@ -123,7 +122,7 @@ class Logger extends BaseLogger implements ServiceLocatorAwareInterface ...@@ -123,7 +122,7 @@ class Logger extends BaseLogger implements ServiceLocatorAwareInterface
$error_types = isset($parts[1]) ? $parts[1] : ''; $error_types = isset($parts[1]) ? $parts[1] : '';
// use smtp // use smtp
$mailer = new Mailer(null, $config); $mailer = $this->getServiceLocator()->get('Mailer');
$msg = $mailer->getNewMessage() $msg = $mailer->getNewMessage()
->addFrom($config->Site->email) ->addFrom($config->Site->email)
->addTo($email) ->addTo($email)
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
* @link http://vufind.org/wiki/system_classes Wiki * @link http://vufind.org/wiki/system_classes Wiki
*/ */
namespace VuFind\Mailer; namespace VuFind\Mailer;
use VuFind\Config\Reader as ConfigReader, VuFind\Exception\Mail as MailException, use VuFind\Config\Reader as ConfigReader, VuFind\Exception\Mail as MailException;
VuFind\Mailer;
/** /**
* VuFind Mailer Class for SMS messages * VuFind Mailer Class for SMS messages
...@@ -38,7 +37,7 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\Mail as MailException ...@@ -38,7 +37,7 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\Mail as MailException
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/system_classes Wiki * @link http://vufind.org/wiki/system_classes Wiki
*/ */
class SMS extends Mailer class SMS extends \VuFind\Mailer
{ {
// Defaults, usually overridden by contents of sms.ini: // Defaults, usually overridden by contents of sms.ini:
protected $carriers = array( protected $carriers = array(
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment