diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index af813e1725a62e3d0f92f13fcff465cbec2151f0..31dc357b3bb6b88b8426e18981657533a79d4ecd 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -320,8 +320,8 @@ $config = [ 'VuFind\Net\IpAddressUtils' => 'Zend\ServiceManager\Factory\InvokableFactory', 'VuFind\Recommend\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory', 'VuFind\Record\Cache' => 'VuFind\Record\CacheFactory', + 'VuFind\Record\Loader' => 'VuFind\Record\LoaderFactory', 'VuFind\RecordDriver\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory', - 'VuFind\RecordLoader' => 'VuFind\Service\Factory::getRecordLoader', 'VuFind\RecordRouter' => 'VuFind\Service\Factory::getRecordRouter', 'VuFind\RecordTab\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory', 'VuFind\Related\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory', @@ -399,6 +399,7 @@ $config = [ 'VuFind\RecommendPluginManager' => 'VuFind\Recommend\PluginManager', 'VuFind\RecordCache' => 'VuFind\Record\Cache', 'VuFind\RecordDriverPluginManager' => 'VuFind\RecordDriver\PluginManager', + 'VuFind\RecordLoader' => 'VuFind\Record\Loader', 'VuFind\RecordTabPluginManager' => 'VuFind\RecordTab\PluginManager', 'VuFind\RelatedPluginManager' => 'VuFind\Related\PluginManager', 'VuFind\ResolverDriverPluginManager' => 'VuFind\Resolver\Driver\PluginManager', diff --git a/module/VuFind/src/VuFind/CartFactory.php b/module/VuFind/src/VuFind/CartFactory.php index 66d8d4afb6382af184d994e6cf781cf1094caa9d..4b975b85ec6e5cd52eb7384ccd0c3bc87c703556 100644 --- a/module/VuFind/src/VuFind/CartFactory.php +++ b/module/VuFind/src/VuFind/CartFactory.php @@ -69,7 +69,7 @@ class CartFactory implements FactoryInterface $activeInSearch = isset($config->Site->bookbagTogglesInSearch) ? $config->Site->bookbagTogglesInSearch : true; return new $requestedName( - $container->get('VuFind\RecordLoader'), + $container->get('VuFind\Record\Loader'), $container->get('VuFind\Cookie\CookieManager'), $size, $active, $activeInSearch ); diff --git a/module/VuFind/src/VuFind/Controller/AbstractBase.php b/module/VuFind/src/VuFind/Controller/AbstractBase.php index 9ec5474f5696f3513e942b5df229823f8e8cb5b5..3c391aa25b52424928f63c802cde7353b9a54277 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractBase.php +++ b/module/VuFind/src/VuFind/Controller/AbstractBase.php @@ -387,7 +387,7 @@ class AbstractBase extends AbstractActionController */ public function getRecordLoader() { - return $this->serviceLocator->get('VuFind\RecordLoader'); + return $this->serviceLocator->get('VuFind\Record\Loader'); } /** diff --git a/module/VuFind/src/VuFind/Controller/AuthorityController.php b/module/VuFind/src/VuFind/Controller/AuthorityController.php index 271ac2a0045c01a89e8ae88c3dd5e85867c506fe..9fa3c32e3ca08223e47ee3daa6318401939d927d 100644 --- a/module/VuFind/src/VuFind/Controller/AuthorityController.php +++ b/module/VuFind/src/VuFind/Controller/AuthorityController.php @@ -78,7 +78,7 @@ class AuthorityController extends AbstractSearch $id = $this->params()->fromQuery('id'); $cfg = $this->serviceLocator->get('Config'); $tabConfig = $cfg['vufind']['recorddriver_tabs']; - $driver = $this->serviceLocator->get('VuFind\RecordLoader') + $driver = $this->serviceLocator->get('VuFind\Record\Loader') ->load($id, 'SolrAuth'); $request = $this->getRequest(); $tabs = $this->serviceLocator diff --git a/module/VuFind/src/VuFind/Controller/HierarchyController.php b/module/VuFind/src/VuFind/Controller/HierarchyController.php index 3f35d9eeb48f8419636a1c1c161cedf2119d5523..c7325ae8b1050666879dd8a52e18290f549bcf02 100644 --- a/module/VuFind/src/VuFind/Controller/HierarchyController.php +++ b/module/VuFind/src/VuFind/Controller/HierarchyController.php @@ -120,7 +120,7 @@ class HierarchyController extends AbstractBase $this->disableSessionWrites(); // avoid session write timing bug // Retrieve the record from the index $id = $this->params()->fromQuery('id'); - $loader = $this->serviceLocator->get('VuFind\RecordLoader'); + $loader = $this->serviceLocator->get('VuFind\Record\Loader'); try { if ($recordDriver = $loader->load($id)) { $results = $recordDriver->getHierarchyDriver()->render( @@ -153,7 +153,7 @@ class HierarchyController extends AbstractBase $this->disableSessionWrites(); // avoid session write timing bug // Retrieve the record from the index $id = $this->params()->fromQuery('id'); - $loader = $this->serviceLocator->get('VuFind\RecordLoader'); + $loader = $this->serviceLocator->get('VuFind\Record\Loader'); try { if ($recordDriver = $loader->load($id)) { $results = $recordDriver->getHierarchyDriver() @@ -183,7 +183,7 @@ class HierarchyController extends AbstractBase public function getrecordAction() { $id = $this->params()->fromQuery('id'); - $loader = $this->serviceLocator->get('VuFind\RecordLoader'); + $loader = $this->serviceLocator->get('VuFind\Record\Loader'); try { $record = $loader->load($id); $result = $this->getViewRenderer()->record($record) diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index 4c1647429692ca15c7ca1ca383153f204d91ca59..4ec3479b1dc38ff98a3a3f15ad4fd4874a9ba9d8 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -940,7 +940,7 @@ class MyResearchController extends AbstractBase $id = isset($current['id']) ? $current['id'] : null; $source = isset($current['source']) ? $current['source'] : DEFAULT_SEARCH_BACKEND; - $record = $this->serviceLocator->get('VuFind\RecordLoader') + $record = $this->serviceLocator->get('VuFind\Record\Loader') ->load($id, $source, true); $record->setExtraDetail('ils_details', $current); return $record; @@ -1364,7 +1364,7 @@ class MyResearchController extends AbstractBase $source = isset($row['source']) ? $row['source'] : DEFAULT_SEARCH_BACKEND; $row['driver'] = $this->serviceLocator - ->get('VuFind\RecordLoader')->load($row['id'], $source); + ->get('VuFind\Record\Loader')->load($row['id'], $source); if (empty($row['title'])) { $row['title'] = $row['driver']->getShortTitle(); } diff --git a/module/VuFind/src/VuFind/Controller/OaiController.php b/module/VuFind/src/VuFind/Controller/OaiController.php index e32d430a06702ad29c328a6dda668d9e3aafd093..e51f006bf38240d59f41d024969bc90b308d4278 100644 --- a/module/VuFind/src/VuFind/Controller/OaiController.php +++ b/module/VuFind/src/VuFind/Controller/OaiController.php @@ -101,7 +101,7 @@ class OaiController extends AbstractBase ); $server = new $serverClass( $this->serviceLocator->get('VuFind\Search\Results\PluginManager'), - $this->serviceLocator->get('VuFind\RecordLoader'), + $this->serviceLocator->get('VuFind\Record\Loader'), $this->serviceLocator->get('VuFind\Db\Table\PluginManager'), $config, $baseURL, $params ); diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Factory.php b/module/VuFind/src/VuFind/Controller/Plugin/Factory.php index 4ed8460df186b325d1fe911b464611eb5fff1f43..98c72f22369bae6f9db77084835244336b983de4 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/Factory.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/Factory.php @@ -52,7 +52,7 @@ class Factory public static function getFavorites(ServiceManager $sm) { return new Favorites( - $sm->get('VuFind\RecordLoader'), + $sm->get('VuFind\Record\Loader'), $sm->get('VuFind\Record\Cache'), $sm->get('VuFind\Tags') ); diff --git a/module/VuFind/src/VuFind/Db/Table/ResourceFactory.php b/module/VuFind/src/VuFind/Db/Table/ResourceFactory.php index 8f85866c0d7ccd7872200ad830711da970fe92d4..4e1237fa1a0a0b9df345ad1303d4307c1398301f 100644 --- a/module/VuFind/src/VuFind/Db/Table/ResourceFactory.php +++ b/module/VuFind/src/VuFind/Db/Table/ResourceFactory.php @@ -61,7 +61,7 @@ class ResourceFactory extends GatewayFactory throw new \Exception('Unexpected options sent to factory!'); } $converter = $container->get('VuFind\Date\Converter'); - $loader = $container->get('VuFind\RecordLoader'); + $loader = $container->get('VuFind\Record\Loader'); return parent::__invoke($container, $requestedName, [$converter, $loader]); } } diff --git a/module/VuFind/src/VuFind/ILS/Driver/NoILSFactory.php b/module/VuFind/src/VuFind/ILS/Driver/NoILSFactory.php index 278d90720cf5b24eeb1a93b79e2cacbafadacce1..7c840591c0f85fc40849e2e2464de3ab44feed34 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/NoILSFactory.php +++ b/module/VuFind/src/VuFind/ILS/Driver/NoILSFactory.php @@ -61,6 +61,6 @@ class NoILSFactory implements FactoryInterface if (!empty($options)) { throw new \Exception('Unexpected options passed to factory.'); } - return new $requestedName($container->get('VuFind\RecordLoader')); + return new $requestedName($container->get('VuFind\Record\Loader')); } } diff --git a/module/VuFind/src/VuFind/ILS/Driver/SymphonyFactory.php b/module/VuFind/src/VuFind/ILS/Driver/SymphonyFactory.php index 9e7e80e545717cb19708666214084e344c56215d..057e113c39053eb7ed35ec2d5122d2ac701b62c3 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/SymphonyFactory.php +++ b/module/VuFind/src/VuFind/ILS/Driver/SymphonyFactory.php @@ -62,7 +62,7 @@ class SymphonyFactory implements FactoryInterface throw new \Exception('Unexpected options passed to factory.'); } return new $requestedName( - $container->get('VuFind\RecordLoader'), + $container->get('VuFind\Record\Loader'), $container->get('VuFind\Cache\Manager') ); } diff --git a/module/VuFind/src/VuFind/Record/LoaderFactory.php b/module/VuFind/src/VuFind/Record/LoaderFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..88d8e7029127e5e0fcbfeff54bf0443a41591232 --- /dev/null +++ b/module/VuFind/src/VuFind/Record/LoaderFactory.php @@ -0,0 +1,70 @@ +<?php +/** + * Record loader factory. + * + * 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 Record + * @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\Record; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + +/** + * Record loader factory. + * + * @category VuFind + * @package Record + * @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 LoaderFactory 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 passed to factory.'); + } + return new $requestedName( + $container->get('VuFind\Search'), + $container->get('VuFind\RecordDriver\PluginManager'), + $container->get('VuFind\Record\Cache') + ); + } +} diff --git a/module/VuFind/src/VuFind/RecordTab/Factory.php b/module/VuFind/src/VuFind/RecordTab/Factory.php index acca252d22eec894c990b96f96bf77425b50731c..e0af17c59b2c2f0cccfd0a518f87c594fdec5581 100644 --- a/module/VuFind/src/VuFind/RecordTab/Factory.php +++ b/module/VuFind/src/VuFind/RecordTab/Factory.php @@ -53,7 +53,7 @@ class Factory { return new CollectionHierarchyTree( $sm->get('VuFind\Config\PluginManager')->get('config'), - $sm->get('VuFind\RecordLoader') + $sm->get('VuFind\Record\Loader') ); } diff --git a/module/VuFind/src/VuFind/Search/Results/PluginFactory.php b/module/VuFind/src/VuFind/Search/Results/PluginFactory.php index e3e9e470ca0264aa778251e336f22bb5d0f48398..231fd0a34671c1591719b5e5304b13882edbdacc 100644 --- a/module/VuFind/src/VuFind/Search/Results/PluginFactory.php +++ b/module/VuFind/src/VuFind/Search/Results/PluginFactory.php @@ -67,7 +67,7 @@ class PluginFactory extends \VuFind\ServiceManager\AbstractPluginFactory $params = $container->get('VuFind\Search\Params\PluginManager') ->get($paramsService); $searchService = $container->get('VuFind\Search'); - $recordLoader = $container->get('VuFind\RecordLoader'); + $recordLoader = $container->get('VuFind\Record\Loader'); $class = $this->getClassName($requestedName); return new $class( $params, $searchService, $recordLoader, ...($extras ?: []) diff --git a/module/VuFind/src/VuFind/Search/Results/ResultsFactory.php b/module/VuFind/src/VuFind/Search/Results/ResultsFactory.php index b58b2a7e3d7e34cc873b81813b5e25a5f9157790..efe5e6db0727068a7f76ef93885f573ddd2271d0 100644 --- a/module/VuFind/src/VuFind/Search/Results/ResultsFactory.php +++ b/module/VuFind/src/VuFind/Search/Results/ResultsFactory.php @@ -63,7 +63,7 @@ class ResultsFactory implements FactoryInterface $params = $container->get('VuFind\Search\Params\PluginManager') ->get($paramsService); $searchService = $container->get('VuFind\Search'); - $recordLoader = $container->get('VuFind\RecordLoader'); + $recordLoader = $container->get('VuFind\Record\Loader'); return new $requestedName( $params, $searchService, $recordLoader, ...($options ?: []) ); diff --git a/module/VuFind/src/VuFind/Service/Factory.php b/module/VuFind/src/VuFind/Service/Factory.php index a79047b4a92f3d97ec832c7fa479be4639a28136..b5e12810b57a211328912ef375a87bf06762649f 100644 --- a/module/VuFind/src/VuFind/Service/Factory.php +++ b/module/VuFind/src/VuFind/Service/Factory.php @@ -116,22 +116,6 @@ class Factory return $config; } - /** - * Construct the record loader. - * - * @param ServiceManager $sm Service manager. - * - * @return \VuFind\Record\Loader - */ - public static function getRecordLoader(ServiceManager $sm) - { - return new \VuFind\Record\Loader( - $sm->get('VuFind\Search'), - $sm->get('VuFind\RecordDriver\PluginManager'), - $sm->get('VuFind\Record\Cache') - ); - } - /** * Construct the record router. * @@ -142,7 +126,7 @@ class Factory public static function getRecordRouter(ServiceManager $sm) { return new \VuFind\Record\Router( - $sm->get('VuFind\RecordLoader'), + $sm->get('VuFind\Record\Loader'), $sm->get('VuFind\Config\PluginManager')->get('config') ); } diff --git a/module/VuFind/src/VuFindTest/Unit/TestCase.php b/module/VuFind/src/VuFindTest/Unit/TestCase.php index acbe0ed614bea97e39fbb2b5747fb6d2f086308d..588c3bd0b57c6f12235932d8b5b5b3864b9466c5 100644 --- a/module/VuFind/src/VuFindTest/Unit/TestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/TestCase.php @@ -200,7 +200,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase 'SharedEventManager', new \Zend\EventManager\SharedEventManager() ); $this->serviceManager->setService( - 'VuFind\RecordLoader', new \VuFind\Record\Loader( + 'VuFind\Record\Loader', new \VuFind\Record\Loader( $this->serviceManager->get('VuFind\Search'), $this->serviceManager->get('VuFind\RecordDriver\PluginManager') ) diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php index b836da4251817085dfb72bbbfdf294b9cd75a1c8..a4f5872b6cc1c42d86e9fec941c875c32ae243a6 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php @@ -68,7 +68,7 @@ class ResultFeedTest extends \VuFindTest\Unit\ViewHelperTestCase ->setConstructorArgs( [ new \VuFind\Record\Router( - $this->getServiceManager()->get('VuFind\RecordLoader'), + $this->getServiceManager()->get('VuFind\Record\Loader'), new \Zend\Config\Config([]) ) ] diff --git a/module/VuFindApi/src/VuFindApi/Controller/SearchApiController.php b/module/VuFindApi/src/VuFindApi/Controller/SearchApiController.php index 5ea4dc3b8f60195ec1b0b49659f841c58ccaca87..f6b71c56117f1ef62c8a22e01b5f4d014a6208e4 100644 --- a/module/VuFindApi/src/VuFindApi/Controller/SearchApiController.php +++ b/module/VuFindApi/src/VuFindApi/Controller/SearchApiController.php @@ -189,7 +189,7 @@ class SearchApiController extends \VuFind\Controller\AbstractSearch return $this->output([], self::STATUS_ERROR, 400, 'Missing id'); } - $loader = $this->serviceLocator->get('VuFind\RecordLoader'); + $loader = $this->serviceLocator->get('VuFind\Record\Loader'); try { if (is_array($request['id'])) { $results = $loader->loadBatchForSource($request['id']); diff --git a/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php b/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php index 56c2cf7aafd6010b75611a57af3ffe7fa268e6ef..2fbfb153865811dbb00f8fa462faa5f0771f21b5 100644 --- a/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php +++ b/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php @@ -605,7 +605,7 @@ class UtilController extends AbstractBase } $skipJson = $request->getParam('skip-json') || $request->getParam('sj'); $skipXml = $request->getParam('skip-xml') || $request->getParam('sx'); - $recordLoader = $this->serviceLocator->get('VuFind\RecordLoader'); + $recordLoader = $this->serviceLocator->get('VuFind\Record\Loader'); $hierarchies = $this->serviceLocator ->get('VuFind\Search\Results\PluginManager')->get('Solr') ->getFullFieldFacets(['hierarchy_top_id']);