From 1851baa299dc1d74cf46840f3a0c11169f79be23 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Mon, 5 Feb 2018 16:47:59 -0500 Subject: [PATCH] Use fully-qualified class name for translator service. - Eliminates redundant/obsolete aliases. --- module/VuFind/config/module.config.php | 5 ++--- module/VuFind/src/VuFind/Bootstrapper.php | 2 +- module/VuFind/src/VuFind/Content/AbstractAmazonFactory.php | 2 +- module/VuFind/src/VuFind/Controller/ContentController.php | 2 +- module/VuFind/src/VuFind/Controller/SearchController.php | 3 ++- module/VuFind/src/VuFind/Controller/SummonController.php | 3 ++- module/VuFind/src/VuFind/Service/Factory.php | 2 +- module/VuFind/src/VuFind/Service/ReCaptchaFactory.php | 2 +- .../VuFind/src/VuFind/ServiceManager/ServiceInitializer.php | 2 +- module/VuFind/src/VuFind/View/Helper/Root/Factory.php | 4 ++-- module/VuFind/src/VuFindTest/Unit/TestCase.php | 3 ++- module/VuFindTheme/src/VuFindTheme/Initializer.php | 2 +- 12 files changed, 17 insertions(+), 15 deletions(-) diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index a9bb5fe7306..246aa1d8d9b 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -345,19 +345,17 @@ $config = [ 'VuFind\SMS\SMSInterface' => 'VuFind\SMS\Factory', 'VuFind\Solr\Writer' => 'VuFind\Solr\WriterFactory', 'VuFind\Tags' => 'VuFind\TagsFactory', - 'VuFind\Translator' => 'VuFind\Service\Factory::getTranslator', 'VuFind\WorldCatUtils' => 'VuFind\Service\Factory::getWorldCatUtils', 'VuFindHttp\HttpService' => 'VuFind\Service\Factory::getHttp', 'VuFindSearch\Service' => 'VuFind\Service\Factory::getSearchService', 'Zend\Db\Adapter\Adapter' => 'VuFind\Service\Factory::getDbAdapter', + 'Zend\Mvc\I18n\Translator' => 'VuFind\Service\Factory::getTranslator', 'Zend\Session\SessionManager' => 'VuFind\Session\ManagerFactory', ], 'initializers' => [ 'VuFind\ServiceManager\ServiceInitializer', ], 'aliases' => [ - 'mvctranslator' => 'VuFind\Translator', - 'translator' => 'VuFind\Translator', 'VuFind\AccountCapabilities' => 'VuFind\Config\AccountCapabilities', 'VuFind\AuthManager' => 'VuFind\Auth\Manager', 'VuFind\AuthPluginManager' => 'VuFind\Auth\PluginManager', @@ -414,6 +412,7 @@ $config = [ 'VuFind\SessionManager' => 'Zend\Session\SessionManager', 'VuFind\SessionPluginManager' => 'VuFind\Session\PluginManager', 'VuFind\SMS' => 'VuFind\SMS\SMSInterface', + 'VuFind\Translator' => 'Zend\Mvc\I18n\Translator', 'VuFind\YamlReader' => 'VuFind\Config\YamlReader', ], ], diff --git a/module/VuFind/src/VuFind/Bootstrapper.php b/module/VuFind/src/VuFind/Bootstrapper.php index e332df55c4b..1c6945aac8c 100644 --- a/module/VuFind/src/VuFind/Bootstrapper.php +++ b/module/VuFind/src/VuFind/Bootstrapper.php @@ -332,7 +332,7 @@ class Bootstrapper $language = $config->Site->language; } try { - $translator = $sm->get('VuFind\Translator'); + $translator = $sm->get('Zend\Mvc\I18n\Translator'); $translator->setLocale($language) ->addTranslationFile('ExtendedIni', null, 'default', $language); foreach ($this->getTextDomains() as $domain) { diff --git a/module/VuFind/src/VuFind/Content/AbstractAmazonFactory.php b/module/VuFind/src/VuFind/Content/AbstractAmazonFactory.php index ae0077c26b8..d46af909f62 100644 --- a/module/VuFind/src/VuFind/Content/AbstractAmazonFactory.php +++ b/module/VuFind/src/VuFind/Content/AbstractAmazonFactory.php @@ -65,7 +65,7 @@ class AbstractAmazonFactory implements \Zend\ServiceManager\Factory\FactoryInter ? $config->Content->amazonassociate : null; $secret = isset($config->Content->amazonsecret) ? $config->Content->amazonsecret : null; - $label = $container->get('VuFind\Translator')->translate( + $label = $container->get('Zend\Mvc\I18n\Translator')->translate( 'Supplied by Amazon' ); return new $requestedName($associate, $secret, $label); diff --git a/module/VuFind/src/VuFind/Controller/ContentController.php b/module/VuFind/src/VuFind/Controller/ContentController.php index e2cd7763bba..607f9d30cd0 100644 --- a/module/VuFind/src/VuFind/Controller/ContentController.php +++ b/module/VuFind/src/VuFind/Controller/ContentController.php @@ -51,7 +51,7 @@ class ContentController extends AbstractBase { $page = $this->params()->fromRoute('page'); $themeInfo = $this->serviceLocator->get('VuFindTheme\ThemeInfo'); - $language = $this->serviceLocator->get('VuFind\Translator') + $language = $this->serviceLocator->get('Zend\Mvc\I18n\Translator') ->getLocale(); $defaultLanguage = $this->getConfig()->Site->language; diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index de357326800..81663a5e896 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -564,7 +564,8 @@ class SearchController extends AbstractSearch // Check if we have facet results cached, and build them if we don't. $cache = $this->serviceLocator->get('VuFind\Cache\Manager') ->getCache('object'); - $language = $this->serviceLocator->get('VuFind\Translator')->getLocale(); + $language = $this->serviceLocator->get('Zend\Mvc\I18n\Translator') + ->getLocale(); $hiddenFilters = $this->getActiveHiddenFilters(); $hiddenFiltersHash = md5(json_encode($hiddenFilters)); $cacheName .= "List-$hiddenFiltersHash-$language"; diff --git a/module/VuFind/src/VuFind/Controller/SummonController.php b/module/VuFind/src/VuFind/Controller/SummonController.php index 29f8cc4ec2e..0a49591aeaa 100644 --- a/module/VuFind/src/VuFind/Controller/SummonController.php +++ b/module/VuFind/src/VuFind/Controller/SummonController.php @@ -158,7 +158,8 @@ class SummonController extends AbstractSearch // Check if we have facet results cached, and build them if we don't. $cache = $this->serviceLocator->get('VuFind\Cache\Manager') ->getCache('object'); - $language = $this->serviceLocator->get('VuFind\Translator')->getLocale(); + $language = $this->serviceLocator->get('Zend\Mvc\I18n\Translator') + ->getLocale(); $cacheKey = 'summonSearchAdvancedFacetsList-' . $language; if (!($list = $cache->getItem($cacheKey))) { $config = $this->serviceLocator->get('VuFind\Config\PluginManager') diff --git a/module/VuFind/src/VuFind/Service/Factory.php b/module/VuFind/src/VuFind/Service/Factory.php index bbef087d1c9..bf3766f7adb 100644 --- a/module/VuFind/src/VuFind/Service/Factory.php +++ b/module/VuFind/src/VuFind/Service/Factory.php @@ -117,7 +117,7 @@ class Factory * * @param ServiceManager $sm Service manager. * - * @return \Zend\I18n\Translator\TranslatorInterface + * @return \Zend\Mvc\I18n\Translator */ public static function getTranslator(ServiceManager $sm) { diff --git a/module/VuFind/src/VuFind/Service/ReCaptchaFactory.php b/module/VuFind/src/VuFind/Service/ReCaptchaFactory.php index 28a902f60a5..0df5c49706e 100644 --- a/module/VuFind/src/VuFind/Service/ReCaptchaFactory.php +++ b/module/VuFind/src/VuFind/Service/ReCaptchaFactory.php @@ -73,7 +73,7 @@ class ReCaptchaFactory implements FactoryInterface ? $config->Captcha->privateKey : ''); $httpClient = $container->get('VuFindHttp\HttpService')->createClient(); - $translator = $container->get('VuFind\Translator'); + $translator = $container->get('Zend\Mvc\I18n\Translator'); $rcOptions = ['lang' => $translator->getLocale()]; if (isset($config->Captcha->theme)) { $rcOptions['theme'] = $config->Captcha->theme; diff --git a/module/VuFind/src/VuFind/ServiceManager/ServiceInitializer.php b/module/VuFind/src/VuFind/ServiceManager/ServiceInitializer.php index 643c632e2dc..712bc8aada1 100644 --- a/module/VuFind/src/VuFind/ServiceManager/ServiceInitializer.php +++ b/module/VuFind/src/VuFind/ServiceManager/ServiceInitializer.php @@ -88,7 +88,7 @@ class ServiceInitializer implements InitializerInterface $instance->setLogger($sm->get('VuFind\Log\Logger')); } if ($instance instanceof \VuFind\I18n\Translator\TranslatorAwareInterface) { - $instance->setTranslator($sm->get('VuFind\Translator')); + $instance->setTranslator($sm->get('Zend\Mvc\I18n\Translator')); } if ($instance instanceof \VuFindHttp\HttpServiceAwareInterface) { $instance->setHttpService($sm->get('VuFindHttp\HttpService')); diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Factory.php b/module/VuFind/src/VuFind/View/Helper/Root/Factory.php index e3231b0c63d..32ed384f808 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Factory.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Factory.php @@ -288,8 +288,8 @@ class Factory */ public static function getHelpText(ServiceManager $sm) { - $lang = $sm->has('VuFind\Translator') - ? $sm->get('VuFind\Translator')->getLocale() + $lang = $sm->has('Zend\Mvc\I18n\Translator') + ? $sm->get('Zend\Mvc\I18n\Translator')->getLocale() : 'en'; $helpers = $sm->get('ViewHelperManager'); return new HelpText($helpers->get('context'), $lang); diff --git a/module/VuFind/src/VuFindTest/Unit/TestCase.php b/module/VuFind/src/VuFindTest/Unit/TestCase.php index 439dac727b7..539145c3432 100644 --- a/module/VuFind/src/VuFindTest/Unit/TestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/TestCase.php @@ -209,7 +209,8 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase $this->serviceManager->setService('Config', []); $factory = new \Zend\Mvc\I18n\TranslatorFactory(); $this->serviceManager->setService( - 'VuFind\Translator', $factory->createService($this->serviceManager) + 'Zend\Mvc\I18n\Translator', + $factory->createService($this->serviceManager) ); } return $this->serviceManager; diff --git a/module/VuFindTheme/src/VuFindTheme/Initializer.php b/module/VuFindTheme/src/VuFindTheme/Initializer.php index 29a1881b52e..51f87b8696a 100644 --- a/module/VuFindTheme/src/VuFindTheme/Initializer.php +++ b/module/VuFindTheme/src/VuFindTheme/Initializer.php @@ -412,7 +412,7 @@ class Initializer if (!empty($pathStack)) { try { - $translator = $this->serviceManager->get('VuFind\Translator'); + $translator = $this->serviceManager->get('Zend\Mvc\I18n\Translator'); $pm = $translator->getPluginManager(); $pm->get('ExtendedIni')->addToPathStack($pathStack); -- GitLab