diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index 532004c3bbdf83b651bd5454cce4caefbf3f6356..ce2b556cdb2c66e162ba50775007dd743f2f4a61 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -311,9 +311,9 @@ $config = [ 'VuFind\Hierarchy\TreeRenderer\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory', 'VuFind\ILS\Connection' => 'VuFind\ILS\ConnectionFactory', 'VuFind\ILS\Driver\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory', - 'VuFind\ILSHoldLogic' => 'VuFind\Service\Factory::getILSHoldLogic', + 'VuFind\ILS\Logic\Holds' => 'VuFind\ILS\Logic\LogicFactory', + 'VuFind\ILS\Logic\TitleHolds' => 'VuFind\ILS\Logic\LogicFactory', 'VuFind\ILSHoldSettings' => 'VuFind\Service\Factory::getILSHoldSettings', - 'VuFind\ILSTitleHoldLogic' => 'VuFind\Service\Factory::getILSTitleHoldLogic', 'VuFind\Logger' => 'VuFind\Log\LoggerFactory', 'VuFind\Mailer' => 'VuFind\Mailer\Factory', 'VuFind\Net\IpAddressUtils' => 'Zend\ServiceManager\Factory\InvokableFactory', @@ -388,6 +388,8 @@ $config = [ 'VuFind\ILSAuthenticator' => 'VuFind\Auth\ILSAuthenticator', 'VuFind\ILSConnection' => 'VuFind\ILS\Connection', 'VuFind\ILSDriverPluginManager' => 'VuFind\ILS\Driver\PluginManager', + 'VuFind\ILSHoldLogic' => 'VuFind\ILS\Logic\Holds', + 'VuFind\ILSTitleHoldLogic' => 'VuFind\ILS\Logic\TitleHolds', 'VuFind\IpAddressUtils' => 'VuFind\Net\IpAddressUtils', 'VuFind\RecommendPluginManager' => 'VuFind\Recommend\PluginManager', 'VuFind\RecordDriverPluginManager' => 'VuFind\RecordDriver\PluginManager', diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php index 9a0b725042f61590d7b27b3bbbf6ef2b9e505142..0357bdcbbfccc65d8ac0d56be8d2e80f4ca4876a 100644 --- a/module/VuFind/src/VuFind/Controller/AjaxController.php +++ b/module/VuFind/src/VuFind/Controller/AjaxController.php @@ -148,7 +148,7 @@ class AjaxController extends AbstractBase { static $hideHoldings = false; if ($hideHoldings === false) { - $logic = $this->serviceLocator->get('VuFind\ILSHoldLogic'); + $logic = $this->serviceLocator->get('VuFind\ILS\Logic\Holds'); $hideHoldings = $logic->getSuppressedLocations(); } diff --git a/module/VuFind/src/VuFind/ILS/Logic/LogicFactory.php b/module/VuFind/src/VuFind/ILS/Logic/LogicFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..3bea86f2d4b0f7957e45c4a16c958cf10b7c2fd6 --- /dev/null +++ b/module/VuFind/src/VuFind/ILS/Logic/LogicFactory.php @@ -0,0 +1,71 @@ +<?php +/** + * Shared factory for ILS logic classes. + * + * PHP version 5 + * + * Copyright (C) Villanova University 2018. + * + * 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 ILS_Logic + * @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 VuFind\ILS\Logic; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + +/** + * Shared factory for ILS logic classes. + * + * @category VuFind + * @package ILS_Logic + * @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 + */ +class LogicFactory implements FactoryInterface +{ + /** + * Create an object + * + * @param ContainerInterface $container Service manager + * @param string $requestedName Service being created + * @param null|array $options Extra options (optional) + * + * @return object + * + * @throws ServiceNotFoundException if unable to resolve the service. + * @throws ServiceNotCreatedException if an exception is raised when + * creating a service. + * @throws ContainerException if any other error occurs + */ + public function __invoke(ContainerInterface $container, $requestedName, + array $options = null + ) { + if (!empty($options)) { + throw new \Exception('Unexpected options sent to factory.'); + } + return new $requestedName( + $container->get('VuFind\Auth\ILSAuthenticator'), + $container->get('VuFind\ILS\Connection'), + $container->get('VuFind\Crypt\HMAC'), + $container->get('VuFind\Config\PluginManager')->get('config') + ); + } +} diff --git a/module/VuFind/src/VuFind/RecordDriver/Factory.php b/module/VuFind/src/VuFind/RecordDriver/Factory.php index afa30b2012c38171823b85a491e9f862e39a5f67..f9d6cae2a759b768422d35eee0275167305cc93f 100644 --- a/module/VuFind/src/VuFind/RecordDriver/Factory.php +++ b/module/VuFind/src/VuFind/RecordDriver/Factory.php @@ -168,8 +168,8 @@ class Factory ); $driver->attachILS( $sm->get('VuFind\ILS\Connection'), - $sm->get('VuFind\ILSHoldLogic'), - $sm->get('VuFind\ILSTitleHoldLogic') + $sm->get('VuFind\ILS\Logic\Holds'), + $sm->get('VuFind\ILS\Logic\TitleHolds') ); $driver->attachSearchService($sm->get('VuFind\Search')); return $driver; @@ -191,8 +191,8 @@ class Factory ); $driver->attachILS( $sm->get('VuFind\ILS\Connection'), - $sm->get('VuFind\ILSHoldLogic'), - $sm->get('VuFind\ILSTitleHoldLogic') + $sm->get('VuFind\ILS\Logic\Holds'), + $sm->get('VuFind\ILS\Logic\TitleHolds') ); $driver->attachSearchService($sm->get('VuFind\Search')); return $driver; diff --git a/module/VuFind/src/VuFind/Service/Factory.php b/module/VuFind/src/VuFind/Service/Factory.php index 31e9a8365e93cf13abb80a3ae30e3d6dea3c0aaa..654fb9ae0970f2dadd3aa7d3fe2b9f6616f65e58 100644 --- a/module/VuFind/src/VuFind/Service/Factory.php +++ b/module/VuFind/src/VuFind/Service/Factory.php @@ -97,23 +97,6 @@ class Factory return new \VuFindHttp\HttpService($options, $defaults); } - /** - * Construct the ILS hold logic. - * - * @param ServiceManager $sm Service manager. - * - * @return \VuFind\ILS\Logic\Holds - */ - public static function getILSHoldLogic(ServiceManager $sm) - { - return new \VuFind\ILS\Logic\Holds( - $sm->get('VuFind\Auth\ILSAuthenticator'), - $sm->get('VuFind\ILS\Connection'), - $sm->get('VuFind\Crypt\HMAC'), - $sm->get('VuFind\Config\PluginManager')->get('config') - ); - } - /** * Construct the ILS hold settings helper. * @@ -128,23 +111,6 @@ class Factory ); } - /** - * Construct the ILS title hold logic. - * - * @param ServiceManager $sm Service manager. - * - * @return \VuFind\ILS\Logic\TitleHolds - */ - public static function getILSTitleHoldLogic(ServiceManager $sm) - { - return new \VuFind\ILS\Logic\TitleHolds( - $sm->get('VuFind\Auth\ILSAuthenticator'), - $sm->get('VuFind\ILS\Connection'), - $sm->get('VuFind\Crypt\HMAC'), - $sm->get('VuFind\Config\PluginManager')->get('config') - ); - } - /** * Construct the ProxyManager configuration. *