From d8840090e987de45d4c58c10aac613d64a47673e Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 19 Oct 2012 11:04:45 -0400 Subject: [PATCH] Prefixed plugin manager service names with "VuFind\" as first step toward best-practice naming for global services. --- module/VuFind/config/module.config.php | 4 +++- module/VuFind/src/VuFind/Auth/Manager.php | 4 ++-- module/VuFind/src/VuFind/Bootstrap.php | 4 ++-- module/VuFind/src/VuFind/Connection/Solr.php | 2 +- module/VuFind/src/VuFind/Controller/AbstractBase.php | 3 ++- module/VuFind/src/VuFind/Controller/AjaxController.php | 6 +++--- .../VuFind/src/VuFind/Controller/MyResearchController.php | 3 ++- module/VuFind/src/VuFind/Controller/SearchController.php | 2 +- module/VuFind/src/VuFind/OAI/Server.php | 3 ++- module/VuFind/src/VuFind/Record/Loader.php | 2 +- module/VuFind/src/VuFind/RecordDriver/AbstractBase.php | 4 ++-- module/VuFind/src/VuFind/Search/Base/Params.php | 7 ++++--- module/VuFind/src/VuFind/Search/Base/Results.php | 3 ++- module/VuFind/src/VuFind/Search/Solr/Results.php | 3 ++- module/VuFind/src/VuFind/Search/SolrAuth/Results.php | 3 ++- module/VuFind/src/VuFind/Search/SolrReserves/Results.php | 3 ++- module/VuFind/src/VuFind/Search/Summon/Results.php | 3 ++- module/VuFind/src/VuFind/Search/WorldCat/Results.php | 3 ++- .../src/VuFind/ServiceManager/AbstractPluginManager.php | 2 +- module/VuFind/src/VuFind/Statistics/AbstractBase.php | 2 +- module/VuFind/src/VuFind/XSLT/Import/VuFind.php | 2 +- module/VuFind/src/VuFindTest/Unit/DbTestCase.php | 6 +++--- module/VuFind/src/VuFindTest/Unit/TestCase.php | 8 ++++---- .../src/VuFindConsole/Controller/AbstractBase.php | 3 ++- 24 files changed, 49 insertions(+), 36 deletions(-) diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index a88ed1a28ba..7f953c9d8aa 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -286,7 +286,9 @@ $config = array( $catalog = new \VuFind\ILS\Connection(); return $catalog ->setConfig(\VuFind\Config\Reader::getConfig()->Catalog) - ->initWithDriverManager($sm->get('ILSDriverPluginManager')); + ->initWithDriverManager( + $sm->get('VuFind\ILSDriverPluginManager') + ); }, 'logger' => function ($sm) { $logger = new \VuFind\Log\Logger(); diff --git a/module/VuFind/src/VuFind/Auth/Manager.php b/module/VuFind/src/VuFind/Auth/Manager.php index 8faef2f7611..18eab5c6d61 100644 --- a/module/VuFind/src/VuFind/Auth/Manager.php +++ b/module/VuFind/src/VuFind/Auth/Manager.php @@ -82,7 +82,7 @@ class Manager implements ServiceLocatorAwareInterface protected function getAuth() { if (!$this->auth) { - $manager = $this->getServiceLocator()->get('AuthPluginManager'); + $manager = $this->getServiceLocator()->get('VuFind\AuthPluginManager'); $this->auth = $manager->get($this->config->Authentication->method); $this->auth->setConfig($this->config); } @@ -196,7 +196,7 @@ class Manager implements ServiceLocatorAwareInterface // restore its service locator, since SL's can't be serialized: if ($user && null === $user->getServiceLocator()) { $user->setServiceLocator( - $this->getServiceLocator()->get('DbTablePluginManager') + $this->getServiceLocator()->get('VuFind\DbTablePluginManager') ); } diff --git a/module/VuFind/src/VuFind/Bootstrap.php b/module/VuFind/src/VuFind/Bootstrap.php index d2364aa2f3e..afa9b0ef9f4 100644 --- a/module/VuFind/src/VuFind/Bootstrap.php +++ b/module/VuFind/src/VuFind/Bootstrap.php @@ -93,7 +93,7 @@ class Bootstrap 'Statistics\Driver' ); foreach ($namespaces as $ns) { - $serviceName = str_replace('\\', '', $ns) . 'PluginManager'; + $serviceName = 'VuFind\\' . str_replace('\\', '', $ns) . 'PluginManager'; $className = 'VuFind\\' . $ns . '\PluginManager'; $configKey = strtolower(str_replace('\\', '_', $ns)) . '_plugin_manager'; $service = new $className( @@ -137,7 +137,7 @@ class Bootstrap // manager and injecting appropriate dependencies: $serviceManager = $this->event->getApplication()->getServiceManager(); $sessionManager = $serviceManager->get('SessionManager'); - $sessionPluginManager = $serviceManager->get('SessionPluginManager'); + $sessionPluginManager = $serviceManager->get('VuFind\SessionPluginManager'); $sessionHandler = $sessionPluginManager->get($this->config->Session->type); $sessionHandler->setConfig($this->config->Session); $sessionManager->setSaveHandler($sessionHandler); diff --git a/module/VuFind/src/VuFind/Connection/Solr.php b/module/VuFind/src/VuFind/Connection/Solr.php index e3b837a1b32..acb38386f6c 100644 --- a/module/VuFind/src/VuFind/Connection/Solr.php +++ b/module/VuFind/src/VuFind/Connection/Solr.php @@ -1156,7 +1156,7 @@ class Solr implements ServiceLocatorAwareInterface // Record the deletions in our change tracker database: foreach ($idList as $id) { - $tracker = $this->getServiceLocator()->get('DbTablePluginManager') + $tracker = $this->getServiceLocator()->get('VuFind\DbTablePluginManager') ->get('ChangeTracker'); $tracker->markDeleted($this->core, $id); } diff --git a/module/VuFind/src/VuFind/Controller/AbstractBase.php b/module/VuFind/src/VuFind/Controller/AbstractBase.php index b63961b3feb..6b84ff05baa 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractBase.php +++ b/module/VuFind/src/VuFind/Controller/AbstractBase.php @@ -228,7 +228,8 @@ class AbstractBase extends AbstractActionController */ public function getTable($table) { - return $this->getServiceLocator()->get('DbTablePluginManager')->get($table); + return $this->getServiceLocator()->get('VuFind\DbTablePluginManager') + ->get($table); } /** diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php index a7e01a832c9..a51c523aa7c 100644 --- a/module/VuFind/src/VuFind/Controller/AjaxController.php +++ b/module/VuFind/src/VuFind/Controller/AjaxController.php @@ -102,7 +102,7 @@ class AjaxController extends AbstractBase // since deferred recommendations work best for modules that don't care about // the details of the search objects anyway: $sm = $this->getSearchManager(); - $rm = $this->getServiceLocator()->get('RecommendPluginManager'); + $rm = $this->getServiceLocator()->get('VuFind\RecommendPluginManager'); $module = $rm->get($this->params()->fromQuery('mod')); $module->setConfig($this->params()->fromQuery('params')); $params = $sm->setSearchClassId('Solr')->getParams(); @@ -919,7 +919,7 @@ class AjaxController extends AbstractBase { $query = $this->getRequest()->getQuery(); $autocompleteManager = $this->getServiceLocator() - ->get('AutocompletePluginManager'); + ->get('VuFind\AutocompletePluginManager'); return $this->output( $autocompleteManager->getSuggestions($query), self::STATUS_OK ); @@ -1219,7 +1219,7 @@ class AjaxController extends AbstractBase $resolverType = isset($config->OpenURL->resolver) ? $config->OpenURL->resolver : 'other'; $pluginManager = $this->getServiceLocator() - ->get('ResolverDriverPluginManager'); + ->get('VuFind\ResolverDriverPluginManager'); if (!$pluginManager->has($resolverType)) { return $this->output( $this->translate("Could not load driver for $resolverType"), diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index d3503b55387..cef4dfe119d 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -743,7 +743,8 @@ class MyResearchController extends AbstractBase $record = $this->getSearchManager()->setSearchClassId('Solr') ->getResults()->getRecord($current['id']); } catch (RecordMissingException $e) { - $factory = $this->getServiceLocator()->get('RecordDriverPluginManager'); + $factory = $this->getServiceLocator() + ->get('VuFind\RecordDriverPluginManager'); $record = $factory->get('Missing'); $record->setRawData( array('id' => isset($current['id']) ? $current['id'] : null) diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index 17cbb8882db..3d764154d09 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -593,7 +593,7 @@ class SearchController extends AbstractSearch // Get suggestions and make sure they are an array (we don't want to JSON // encode them into an object): $autocompleteManager = $this->getServiceLocator() - ->get('AutocompletePluginManager'); + ->get('VuFind\AutocompletePluginManager'); $suggestions = $autocompleteManager->getSuggestions( $query, 'type', 'lookfor' ); diff --git a/module/VuFind/src/VuFind/OAI/Server.php b/module/VuFind/src/VuFind/OAI/Server.php index d4cd1d6f9d0..2029f7a812c 100644 --- a/module/VuFind/src/VuFind/OAI/Server.php +++ b/module/VuFind/src/VuFind/OAI/Server.php @@ -78,7 +78,8 @@ class Server public function __construct(\VuFind\Search\Manager $sm, $baseURL, $params) { $this->searchManager = $sm; - $this->tableManager = $sm->getServiceLocator()->get('DbTablePluginManager'); + $this->tableManager = $sm->getServiceLocator() + ->get('VuFind\DbTablePluginManager'); $this->baseURL = $baseURL; $this->params = isset($params) && is_array($params) ? $params : array(); $this->initializeMetadataFormats(); // Load details on supported formats diff --git a/module/VuFind/src/VuFind/Record/Loader.php b/module/VuFind/src/VuFind/Record/Loader.php index 6ed4c6040fd..9ffbfc87a63 100644 --- a/module/VuFind/src/VuFind/Record/Loader.php +++ b/module/VuFind/src/VuFind/Record/Loader.php @@ -133,7 +133,7 @@ class Loader implements ServiceLocatorAwareInterface ? $details['extra_fields'] : array(); $fields['id'] = $details['id']; $factory = $this->getServiceLocator() - ->get('RecordDriverPluginManager'); + ->get('VuFind\RecordDriverPluginManager'); $retVal[$i] = $factory->get('Missing'); $retVal[$i]->setRawData($fields); $retVal[$i]->setResourceSource($details['source']); diff --git a/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php b/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php index ec95ed9f576..9a5494c8313 100644 --- a/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php +++ b/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php @@ -279,7 +279,7 @@ abstract class AbstractBase implements ServiceLocatorAwareInterface $type = $parts[0]; $params = isset($parts[1]) ? $parts[1] : null; $factory = $this->getServiceLocator()->getServiceLocator() - ->get('RelatedPluginManager'); + ->get('VuFind\RelatedPluginManager'); if ($factory->has($type)) { $plugin = $factory->get($type); $plugin->init($params, $this); @@ -468,7 +468,7 @@ abstract class AbstractBase implements ServiceLocatorAwareInterface protected function getDbTable($table) { return $this->getServiceLocator()->getServiceLocator() - ->get('DbTablePluginManager')->get($table); + ->get('VuFind\DbTablePluginManager')->get($table); } /** diff --git a/module/VuFind/src/VuFind/Search/Base/Params.php b/module/VuFind/src/VuFind/Search/Base/Params.php index 3db4d1c9c09..7d825cba120 100644 --- a/module/VuFind/src/VuFind/Search/Base/Params.php +++ b/module/VuFind/src/VuFind/Search/Base/Params.php @@ -792,10 +792,10 @@ class Params implements ServiceLocatorAwareInterface // Get the plugin manager (skip recommendations if it is unavailable): $sm = $this->getServiceLocator(); - if (!is_object($sm) || !$sm->has('RecommendPluginManager')) { + if (!is_object($sm) || !$sm->has('VuFind\RecommendPluginManager')) { return; } - $manager = $sm->get('RecommendPluginManager'); + $manager = $sm->get('VuFind\RecommendPluginManager'); // Process recommendations for each location: $this->recommend = array( @@ -1560,7 +1560,8 @@ class Params implements ServiceLocatorAwareInterface */ public function getTable($table) { - return $this->getServiceLocator()->get('DbTablePluginManager')->get($table); + return $this->getServiceLocator()->get('VuFind\DbTablePluginManager') + ->get($table); } /** diff --git a/module/VuFind/src/VuFind/Search/Base/Results.php b/module/VuFind/src/VuFind/Search/Base/Results.php index 40289062454..ef4d5b378e3 100644 --- a/module/VuFind/src/VuFind/Search/Base/Results.php +++ b/module/VuFind/src/VuFind/Search/Base/Results.php @@ -611,7 +611,8 @@ abstract class Results implements ServiceLocatorAwareInterface */ public function getTable($table) { - return $this->getServiceLocator()->get('DbTablePluginManager')->get($table); + return $this->getServiceLocator()->get('VuFind\DbTablePluginManager') + ->get($table); } /** diff --git a/module/VuFind/src/VuFind/Search/Solr/Results.php b/module/VuFind/src/VuFind/Search/Solr/Results.php index 1e9e6a280a3..232e2a9fe90 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Results.php +++ b/module/VuFind/src/VuFind/Search/Solr/Results.php @@ -537,7 +537,8 @@ class Results extends BaseResults */ protected function initRecordDriver($data) { - $factory = $this->getServiceLocator()->get('RecordDriverPluginManager'); + $factory = $this->getServiceLocator() + ->get('VuFind\RecordDriverPluginManager'); $key = 'Solr' . ucwords($data['recordtype']); $recordType = $factory->has($key) ? $key : 'SolrDefault'; diff --git a/module/VuFind/src/VuFind/Search/SolrAuth/Results.php b/module/VuFind/src/VuFind/Search/SolrAuth/Results.php index 35fb26ebb19..4c54cb5e98c 100644 --- a/module/VuFind/src/VuFind/Search/SolrAuth/Results.php +++ b/module/VuFind/src/VuFind/Search/SolrAuth/Results.php @@ -63,7 +63,8 @@ class Results extends \VuFind\Search\Solr\Results */ protected function initRecordDriver($data) { - $factory = $this->getServiceLocator()->get('RecordDriverPluginManager'); + $factory = $this->getServiceLocator() + ->get('VuFind\RecordDriverPluginManager'); $driver = $factory->get('SolrAuth'); $driver->setRawData($data); return $driver; diff --git a/module/VuFind/src/VuFind/Search/SolrReserves/Results.php b/module/VuFind/src/VuFind/Search/SolrReserves/Results.php index 0b3038b7d5b..1a11649d02a 100644 --- a/module/VuFind/src/VuFind/Search/SolrReserves/Results.php +++ b/module/VuFind/src/VuFind/Search/SolrReserves/Results.php @@ -65,7 +65,8 @@ class Results extends \VuFind\Search\Solr\Results */ protected function initRecordDriver($data) { - $factory = $this->getServiceLocator()->get('RecordDriverPluginManager'); + $factory = $this->getServiceLocator() + ->get('VuFind\RecordDriverPluginManager'); $driver = $factory->get('SolrReserves'); $driver->setRawData($data); return $driver; diff --git a/module/VuFind/src/VuFind/Search/Summon/Results.php b/module/VuFind/src/VuFind/Search/Summon/Results.php index efe1dce981f..daa34c865ec 100644 --- a/module/VuFind/src/VuFind/Search/Summon/Results.php +++ b/module/VuFind/src/VuFind/Search/Summon/Results.php @@ -160,7 +160,8 @@ class Results extends BaseResults */ protected function initRecordDriver($data) { - $factory = $this->getServiceLocator()->get('RecordDriverPluginManager'); + $factory = $this->getServiceLocator() + ->get('VuFind\RecordDriverPluginManager'); $driver = $factory->get('Summon'); $driver->setRawData($data); return $driver; diff --git a/module/VuFind/src/VuFind/Search/WorldCat/Results.php b/module/VuFind/src/VuFind/Search/WorldCat/Results.php index bd219419d7c..345aea6b8d1 100644 --- a/module/VuFind/src/VuFind/Search/WorldCat/Results.php +++ b/module/VuFind/src/VuFind/Search/WorldCat/Results.php @@ -124,7 +124,8 @@ class Results extends BaseResults */ protected function initRecordDriver($data) { - $factory = $this->getServiceLocator()->get('RecordDriverPluginManager'); + $factory = $this->getServiceLocator() + ->get('VuFind\RecordDriverPluginManager'); $driver = $factory->get('WorldCat'); $driver->setRawData($data); return $driver; diff --git a/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManager.php b/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManager.php index 7e71e9f88ad..0b71c1c4169 100644 --- a/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManager.php +++ b/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManager.php @@ -54,7 +54,7 @@ abstract class AbstractPluginManager extends Base $initializer = function ($instance, $manager) { if ($instance instanceof \VuFind\Db\Table\DbTableAwareInterface) { $instance->setDbTableManager( - $manager->getServiceLocator()->get('DbTablePluginManager') + $manager->getServiceLocator()->get('VuFind\DbTablePluginManager') ); } if (method_exists($instance, 'setPluginManager')) { diff --git a/module/VuFind/src/VuFind/Statistics/AbstractBase.php b/module/VuFind/src/VuFind/Statistics/AbstractBase.php index d157f456a05..0683f1d7e8a 100644 --- a/module/VuFind/src/VuFind/Statistics/AbstractBase.php +++ b/module/VuFind/src/VuFind/Statistics/AbstractBase.php @@ -139,7 +139,7 @@ abstract class AbstractBase implements ServiceLocatorAwareInterface // If we got this far, we want the current option! Build the driver: $loader = $this->getServiceLocator() - ->get('StatisticsDriverPluginManager'); + ->get('VuFind\StatisticsDriverPluginManager'); $newDriver = $loader->get($setting[0]); // Set the name of the data source; we use the special value diff --git a/module/VuFind/src/VuFind/XSLT/Import/VuFind.php b/module/VuFind/src/VuFind/XSLT/Import/VuFind.php index 03e4930f74b..648c210a546 100644 --- a/module/VuFind/src/VuFind/XSLT/Import/VuFind.php +++ b/module/VuFind/src/VuFind/XSLT/Import/VuFind.php @@ -62,7 +62,7 @@ class VuFind */ public static function getChangeTracker() { - return static::$serviceLocator->get('DbTablePluginManager') + return static::$serviceLocator->get('VuFind\DbTablePluginManager') ->get('ChangeTracker'); } diff --git a/module/VuFind/src/VuFindTest/Unit/DbTestCase.php b/module/VuFind/src/VuFindTest/Unit/DbTestCase.php index 4d1959da133..08121c7f2e6 100644 --- a/module/VuFind/src/VuFindTest/Unit/DbTestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/DbTestCase.php @@ -51,7 +51,7 @@ abstract class DbTestCase extends TestCase $sm = parent::getServiceManager(); // Add database service: - if (!$sm->has('DbTablePluginManager')) { + if (!$sm->has('VuFind\DbTablePluginManager')) { $sm->setService('DBAdapter', \VuFind\Db\AdapterFactory::getAdapter()); $factory = new \VuFind\Db\Table\PluginManager( new \Zend\ServiceManager\Config( @@ -62,7 +62,7 @@ abstract class DbTestCase extends TestCase ) ); $factory->setServiceLocator($sm); - $sm->setService('DbTablePluginManager', $factory); + $sm->setService('VuFind\DbTablePluginManager', $factory); } return $sm; } @@ -77,6 +77,6 @@ abstract class DbTestCase extends TestCase public function getTable($table) { $sm = $this->getServiceManager(); - return $sm->get('DbTablePluginManager')->get($table); + return $sm->get('VuFind\DbTablePluginManager')->get($table); } } \ No newline at end of file diff --git a/module/VuFind/src/VuFindTest/Unit/TestCase.php b/module/VuFind/src/VuFindTest/Unit/TestCase.php index d8330504aa5..912d9190906 100644 --- a/module/VuFind/src/VuFindTest/Unit/TestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/TestCase.php @@ -125,7 +125,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase ); $this->serviceManager = new \Zend\ServiceManager\ServiceManager(); $this->serviceManager->setService( - 'RecordDriverPluginManager', $recordDriverFactory + 'VuFind\RecordDriverPluginManager', $recordDriverFactory ); $this->serviceManager->setService( 'SearchSpecsReader', new \VuFind\Config\SearchSpecsReader() @@ -146,7 +146,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase public function getAuthManager() { $sm = $this->getServiceManager(); - if (!$sm->has('AuthPluginManager')) { + if (!$sm->has('VuFind\AuthPluginManager')) { $authManager = new \VuFind\Auth\PluginManager( new \Zend\ServiceManager\Config( array( @@ -164,9 +164,9 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase ) ); $authManager->setServiceLocator($sm); - $sm->setService('AuthPluginManager', $authManager); + $sm->setService('VuFind\AuthPluginManager', $authManager); } - return $sm->get('AuthPluginManager'); + return $sm->get('VuFind\AuthPluginManager'); } /** diff --git a/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php b/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php index 1a23b0988ac..324448d0ac3 100644 --- a/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php +++ b/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php @@ -119,6 +119,7 @@ class AbstractBase extends AbstractActionController */ public function getTable($table) { - return $this->getServiceLocator()->get('DbTablePluginManager')->get($table); + return $this->getServiceLocator()->get('VuFind\DbTablePluginManager') + ->get($table); } } \ No newline at end of file -- GitLab