diff --git a/module/VuFind/src/VuFind/Search/BackendRegistry.php b/module/VuFind/src/VuFind/Search/BackendRegistry.php new file mode 100644 index 0000000000000000000000000000000000000000..8d7bf48cebe7a3a3e15f8753057f1ab1df25c63a --- /dev/null +++ b/module/VuFind/src/VuFind/Search/BackendRegistry.php @@ -0,0 +1,52 @@ +<?php + +/** + * Registry for search backends. + * + * PHP version 5 + * + * Copyright (C) Villanova University 2017. + * + * 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 Search + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Site + */ +namespace VuFind\Search; + +/** + * Registry for search backends. + * + * @category VuFind + * @package Search + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Site + */ +class BackendRegistry extends \VuFind\ServiceManager\AbstractPluginManager +{ + /** + * Return the name of the base class or interface that plug-ins must conform + * to. + * + * @return string + */ + protected function getExpectedInterface() + { + return 'VuFindSearch\Backend\BackendInterface'; + } +} diff --git a/module/VuFind/src/VuFind/Search/Factory/AbstractSolrBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/AbstractSolrBackendFactory.php index 5596ca2d9d05dc61f630146ca783db0862ea3894..9c9c2c8620287b00f479d9be0ef919aa7c91a478 100644 --- a/module/VuFind/src/VuFind/Search/Factory/AbstractSolrBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/AbstractSolrBackendFactory.php @@ -135,7 +135,7 @@ abstract class AbstractSolrBackendFactory implements FactoryInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { - $this->serviceLocator = $serviceLocator; + $this->serviceLocator = $serviceLocator->getServiceLocator(); $this->config = $this->serviceLocator->get('VuFind\Config'); if ($this->serviceLocator->has('VuFind\Logger')) { $this->logger = $this->serviceLocator->get('VuFind\Logger'); diff --git a/module/VuFind/src/VuFind/Search/Factory/BrowZineBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/BrowZineBackendFactory.php index 6aa853f63d165b17e46678bb14bd4784fe0d969d..faafd2f702c121f7cd2c6c5f1a29f849b119ccb4 100644 --- a/module/VuFind/src/VuFind/Search/Factory/BrowZineBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/BrowZineBackendFactory.php @@ -77,7 +77,7 @@ class BrowZineBackendFactory implements FactoryInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { - $this->serviceLocator = $serviceLocator; + $this->serviceLocator = $serviceLocator->getServiceLocator(); $configReader = $this->serviceLocator->get('VuFind\Config'); $this->browzineConfig = $configReader->get('BrowZine'); if ($this->serviceLocator->has('VuFind\Logger')) { diff --git a/module/VuFind/src/VuFind/Search/Factory/EITBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/EITBackendFactory.php index a427ce93cfc9100767d414d326645c7d951656c9..8eec6fc50dab2d2acbd637c32bd57d0854b08263 100644 --- a/module/VuFind/src/VuFind/Search/Factory/EITBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/EITBackendFactory.php @@ -79,7 +79,7 @@ class EITBackendFactory implements FactoryInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { - $this->serviceLocator = $serviceLocator; + $this->serviceLocator = $serviceLocator->getServiceLocator(); $this->config = $this->serviceLocator->get('VuFind\Config')->get('EIT'); if ($this->serviceLocator->has('VuFind\Logger')) { $this->logger = $this->serviceLocator->get('VuFind\Logger'); diff --git a/module/VuFind/src/VuFind/Search/Factory/EdsBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/EdsBackendFactory.php index 62e6d26d9373cafb8670a660f5954f763c41a118..6f265388adf8502ae8cc6422eeb359ae68cf3db5 100644 --- a/module/VuFind/src/VuFind/Search/Factory/EdsBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/EdsBackendFactory.php @@ -85,7 +85,7 @@ class EdsBackendFactory implements FactoryInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { - $this->serviceLocator = $serviceLocator; + $this->serviceLocator = $serviceLocator->getServiceLocator(); $this->edsConfig = $this->serviceLocator->get('VuFind\Config')->get('EDS'); if ($this->serviceLocator->has('VuFind\Logger')) { $this->logger = $this->serviceLocator->get('VuFind\Logger'); diff --git a/module/VuFind/src/VuFind/Search/Factory/LibGuidesBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/LibGuidesBackendFactory.php index d391d388ce6dbb11d17fb94672b4521688434767..414c12b77784b4efc2cc2231d3e20dc67ec0d639 100644 --- a/module/VuFind/src/VuFind/Search/Factory/LibGuidesBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/LibGuidesBackendFactory.php @@ -78,7 +78,7 @@ class LibGuidesBackendFactory implements FactoryInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { - $this->serviceLocator = $serviceLocator; + $this->serviceLocator = $serviceLocator->getServiceLocator(); $configReader = $this->serviceLocator->get('VuFind\Config'); $this->libGuidesConfig = $configReader->get('LibGuides'); if ($this->serviceLocator->has('VuFind\Logger')) { diff --git a/module/VuFind/src/VuFind/Search/Factory/Pazpar2BackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/Pazpar2BackendFactory.php index c58fe31d6cc16d1cdd2d972ce33f8c245ab565c8..93d2f22833fe9ce949941d31f623bbc685eca514 100644 --- a/module/VuFind/src/VuFind/Search/Factory/Pazpar2BackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/Pazpar2BackendFactory.php @@ -78,7 +78,7 @@ class Pazpar2BackendFactory implements FactoryInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { - $this->serviceLocator = $serviceLocator; + $this->serviceLocator = $serviceLocator->getServiceLocator(); $this->config = $this->serviceLocator->get('VuFind\Config')->get('Pazpar2'); if ($this->serviceLocator->has('VuFind\Logger')) { $this->logger = $this->serviceLocator->get('VuFind\Logger'); diff --git a/module/VuFind/src/VuFind/Search/Factory/PrimoBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/PrimoBackendFactory.php index 9604bfdd82d5f021b2e1fccd5e35b807450dd281..2d819402bf6b4a09b264867e4861f5e8bfc37fb9 100644 --- a/module/VuFind/src/VuFind/Search/Factory/PrimoBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/PrimoBackendFactory.php @@ -81,7 +81,7 @@ class PrimoBackendFactory implements FactoryInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { - $this->serviceLocator = $serviceLocator; + $this->serviceLocator = $serviceLocator->getServiceLocator(); $configReader = $this->serviceLocator->get('VuFind\Config'); $this->primoConfig = $configReader->get('Primo'); if ($this->serviceLocator->has('VuFind\Logger')) { diff --git a/module/VuFind/src/VuFind/Search/Factory/SummonBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/SummonBackendFactory.php index cdb5ffff0628223926e9c8d5a7bdc737fd6bc059..fc3b78b7c1373a93e5161591bf38700fbdfb9ba4 100644 --- a/module/VuFind/src/VuFind/Search/Factory/SummonBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/SummonBackendFactory.php @@ -86,7 +86,7 @@ class SummonBackendFactory implements FactoryInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { - $this->serviceLocator = $serviceLocator; + $this->serviceLocator = $serviceLocator->getServiceLocator(); $configReader = $this->serviceLocator->get('VuFind\Config'); $this->config = $configReader->get('config'); $this->summonConfig = $configReader->get('Summon'); diff --git a/module/VuFind/src/VuFind/Search/Factory/WorldCatBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/WorldCatBackendFactory.php index e957aa86b841b4625a192c65f60fc899646ed5e1..030778b6c82aa2aa743cb7ff2c2af626f27cd92d 100644 --- a/module/VuFind/src/VuFind/Search/Factory/WorldCatBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/WorldCatBackendFactory.php @@ -85,7 +85,7 @@ class WorldCatBackendFactory implements FactoryInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { - $this->serviceLocator = $serviceLocator; + $this->serviceLocator = $serviceLocator->getServiceLocator(); $this->config = $this->serviceLocator->get('VuFind\Config')->get('config'); $this->wcConfig = $this->serviceLocator ->get('VuFind\Config')->get('WorldCat'); diff --git a/module/VuFind/src/VuFind/Service/Factory.php b/module/VuFind/src/VuFind/Service/Factory.php index 94314f222824539e0d44b5a4a6cc0e2115e3f706..94c779f887d0613d7fa8d94377ddd6fcc79e2671 100644 --- a/module/VuFind/src/VuFind/Service/Factory.php +++ b/module/VuFind/src/VuFind/Service/Factory.php @@ -736,11 +736,9 @@ class Factory public static function getSearchBackendManager(ServiceManager $sm) { $config = $sm->get('config'); - $smConfig = new \Zend\ServiceManager\Config( - $config['vufind']['plugin_managers']['search_backend'] + $registry = new \VuFind\Search\BackendRegistry( + $sm, $config['vufind']['plugin_managers']['search_backend'] ); - $registry = $sm->createScopedServiceManager(); - $smConfig->configureServiceManager($registry); $manager = new \VuFind\Search\BackendManager($registry); return $manager; diff --git a/module/VuFind/src/VuFindTest/Unit/TestCase.php b/module/VuFind/src/VuFindTest/Unit/TestCase.php index 1402b9f656fa9c897f109d46d3bfcb42312b9093..d758182f105bc1de60e3fe7b405412409099fa2d 100644 --- a/module/VuFind/src/VuFindTest/Unit/TestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/TestCase.php @@ -112,16 +112,15 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase */ protected function setupSearchService() { - $smConfig = new \Zend\ServiceManager\Config( - [ - 'factories' => [ - 'Solr' => 'VuFind\Search\Factory\SolrDefaultBackendFactory', - 'SolrAuth' => 'VuFind\Search\Factory\SolrAuthBackendFactory', - ] + $config = [ + 'factories' => [ + 'Solr' => 'VuFind\Search\Factory\SolrDefaultBackendFactory', + 'SolrAuth' => 'VuFind\Search\Factory\SolrAuthBackendFactory', ] + ]; + $registry = new \VuFind\Search\BackendRegistry( + $this->serviceManager, $config ); - $registry = $this->serviceManager->createScopedServiceManager(); - $smConfig->configureServiceManager($registry); $bm = new \VuFind\Search\BackendManager($registry); $this->serviceManager->setService('VuFind\Search\BackendManager', $bm); $ss = new \VuFindSearch\Service();