From 56fe8de4b19463aa2dc6009dbe3bfccaf5eff764 Mon Sep 17 00:00:00 2001 From: Sebastian Kehr <kehr@ub.uni-leipzig.de> Date: Wed, 10 Jul 2019 11:48:35 +0200 Subject: [PATCH] refs #15644 [master] use mailer core factory --- module/finc/config/module.config.php | 1 - module/finc/src/finc/Mailer/Factory.php | 102 ------------------------ 2 files changed, 103 deletions(-) delete mode 100644 module/finc/src/finc/Mailer/Factory.php diff --git a/module/finc/config/module.config.php b/module/finc/config/module.config.php index 2565b99febb..0eb076b1932 100644 --- a/module/finc/config/module.config.php +++ b/module/finc/config/module.config.php @@ -9,7 +9,6 @@ use VuFind\Controller\AbstractBaseWithConfigFactory; $config = [ 'service_manager' => [ 'factories' => [ - 'VuFind\Mailer' => 'finc\Mailer\Factory', 'VuFind\Cache\Manager' => 'finc\Service\Factory::getCacheManager', 'VuFind\BranchesReader' => 'finc\Service\Factory::getBranchesReader', 'VuFind\ILS\Connection' => 'finc\Service\Factory::getILSConnection', diff --git a/module/finc/src/finc/Mailer/Factory.php b/module/finc/src/finc/Mailer/Factory.php deleted file mode 100644 index eca49ea9ba4..00000000000 --- a/module/finc/src/finc/Mailer/Factory.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php -/** - * Factory for instantiating Mailer objects - * - * PHP version 5 - * - * Copyright (C) Villanova University 2009. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * @category VuFind - * @package Mailer - * @author Demian Katz <demian.katz@villanova.edu> - * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License - * @link https://vufind.org/wiki/development Wiki - */ -namespace finc\Mailer; - -use Zend\Mail\Transport\InMemory; -use Zend\Mail\Transport\Smtp; -use Zend\Mail\Transport\SmtpOptions; -use Zend\ServiceManager\ServiceLocatorInterface; - -/** - * Factory for instantiating Mailer objects - * - * @category VuFind - * @package Mailer - * @author Demian Katz <demian.katz@villanova.edu> - * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License - * @link https://vufind.org/wiki/development Wiki - * - * @codeCoverageIgnore - */ -class Factory implements \Zend\ServiceManager\FactoryInterface -{ - /** - * Build the mail transport object. - * - * @param \Zend\Config\Config $config Configuration - * - * @return InMemory|Smtp - */ - protected function getTransport($config) - { - // In test mode? Return fake object: - if (isset($config->Mail->testOnly) && $config->Mail->testOnly) { - return new InMemory(); - } - - // Create mail transport: - $settings = [ - 'host' => $config->Mail->host, 'port' => $config->Mail->port - ]; - if (isset($config->Mail->username) && isset($config->Mail->password)) { - $settings['connection_class'] = 'login'; - $settings['connection_config'] = [ - 'username' => $config->Mail->username, - 'password' => $config->Mail->password - ]; - if (isset($config->Mail->secure)) { - // always set user defined secure connection - $settings['connection_config']['ssl'] = $config->Mail->secure; - } else { - // set default secure connection based on configured port - if ($settings['port'] == '587') { - $settings['connection_config']['ssl'] = 'tls'; - } elseif ($settings['port'] == '487') { - $settings['connection_config']['ssl'] = 'ssl'; - } - } - } - return new Smtp(new SmtpOptions($settings)); - } - - /** - * Create service - * - * @param ServiceLocatorInterface $sm Service manager - * - * @return mixed - */ - public function createService(ServiceLocatorInterface $sm) - { - // Load configurations: - $config = $sm->get('VuFind\Config')->get('config'); - - // Create service: - return new \VuFind\Mailer\Mailer($this->getTransport($config)); - } -} -- GitLab