diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index d75680ae59aef3c639357c693e20d4a934e29ece..a161bb26b1f4f66aa4c6f0eeae88968888a2de80 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -290,6 +290,7 @@ $config = [ 'VuFind\ChannelProvider\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory', 'VuFind\Config\AccountCapabilities' => 'VuFind\Config\AccountCapabilitiesFactory', 'VuFind\Config\PluginManager' => 'VuFind\Config\PluginManagerFactory', + 'VuFind\Config\YamlReader' => 'VuFind\Config\YamlReaderFactory', 'VuFind\Content\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory', 'VuFind\Content\AuthorNotes\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory', 'VuFind\Content\Covers\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory', @@ -347,7 +348,6 @@ $config = [ 'VuFind\Tags' => 'VuFind\Service\Factory::getTags', 'VuFind\Translator' => 'VuFind\Service\Factory::getTranslator', 'VuFind\WorldCatUtils' => 'VuFind\Service\Factory::getWorldCatUtils', - 'VuFind\YamlReader' => 'VuFind\Service\Factory::getYamlReader', 'VuFindHttp\HttpService' => 'VuFind\Service\Factory::getHttp', 'VuFindSearch\Service' => 'VuFind\Service\Factory::getSearchService', 'Zend\Db\Adapter\Adapter' => 'VuFind\Service\Factory::getDbAdapter', @@ -409,6 +409,7 @@ $config = [ 'VuFind\SearchParamsPluginManager' => 'VuFind\Search\Params\PluginManager', 'VuFind\SearchResultsPluginManager' => 'VuFind\Search\Results\PluginManager', 'VuFind\SearchRunner' => 'VuFind\Search\SearchRunner', + 'VuFind\YamlReader' => 'VuFind\Config\YamlReader', ], ], 'translator' => [], diff --git a/module/VuFind/src/VuFind/Config/YamlReaderFactory.php b/module/VuFind/src/VuFind/Config/YamlReaderFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..e779b00d22cbd2eb1a9259ccae254c7d8255c5de --- /dev/null +++ b/module/VuFind/src/VuFind/Config/YamlReaderFactory.php @@ -0,0 +1,66 @@ +<?php +/** + * Factory for YamlReader (and subclasses). + * + * 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 Config + * @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\Config; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + +/** + * Factory for YamlReader (and subclasses). + * + * @category VuFind + * @package Config + * @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 YamlReaderFactory 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\Cache\Manager')); + } +} diff --git a/module/VuFind/src/VuFind/Service/Factory.php b/module/VuFind/src/VuFind/Service/Factory.php index c71ccdb653ffe9098a535fabab084165b60c0533..c8903c701deedd7a620df76628e60f6c49611de6 100644 --- a/module/VuFind/src/VuFind/Service/Factory.php +++ b/module/VuFind/src/VuFind/Service/Factory.php @@ -265,18 +265,4 @@ class Factory $client, true, $ip ); } - - /** - * Construct the YAML reader. - * - * @param ServiceManager $sm Service manager. - * - * @return \VuFind\Config\YamlReader - */ - public static function getYamlReader(ServiceManager $sm) - { - return new \VuFind\Config\YamlReader( - $sm->get('VuFind\Cache\Manager') - ); - } } diff --git a/module/VuFindApi/src/VuFindApi/Controller/Factory.php b/module/VuFindApi/src/VuFindApi/Controller/Factory.php index efc39673904dcf4fb0743cfc79d6d3c1a91eb386..6b60fe6ec47ffa4ccb0632e02116b2c7690771e6 100644 --- a/module/VuFindApi/src/VuFindApi/Controller/Factory.php +++ b/module/VuFindApi/src/VuFindApi/Controller/Factory.php @@ -67,7 +67,7 @@ class Factory */ public static function getSearchApiController(ServiceManager $sm) { - $recordFields = $sm->get('VuFind\YamlReader') + $recordFields = $sm->get('VuFind\Config\YamlReader') ->get('SearchApiRecordFields.yaml'); $helperManager = $sm->get('ViewHelperManager'); $rf = new RecordFormatter($recordFields, $helperManager);