diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index ec4c611fba484966a95fe5cd5857815c09cf48cf..a9bb5fe73066d42fe3ee2f49ea54e632700ec3a8 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -344,7 +344,7 @@ $config = [ 'VuFind\Session\Settings' => 'Zend\ServiceManager\Factory\InvokableFactory', 'VuFind\SMS\SMSInterface' => 'VuFind\SMS\Factory', 'VuFind\Solr\Writer' => 'VuFind\Solr\WriterFactory', - 'VuFind\Tags' => 'VuFind\Service\Factory::getTags', + 'VuFind\Tags' => 'VuFind\TagsFactory', 'VuFind\Translator' => 'VuFind\Service\Factory::getTranslator', 'VuFind\WorldCatUtils' => 'VuFind\Service\Factory::getWorldCatUtils', 'VuFindHttp\HttpService' => 'VuFind\Service\Factory::getHttp', diff --git a/module/VuFind/src/VuFind/Service/Factory.php b/module/VuFind/src/VuFind/Service/Factory.php index 349c0e30c8b6669fa56e2073b289b22a1f297304..bbef087d1c979899889d868ca43c47c7549ff747 100644 --- a/module/VuFind/src/VuFind/Service/Factory.php +++ b/module/VuFind/src/VuFind/Service/Factory.php @@ -112,21 +112,6 @@ class Factory ); } - /** - * Construct the tag helper. - * - * @param ServiceManager $sm Service manager. - * - * @return \VuFind\Tags - */ - public static function getTags(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager')->get('config'); - $maxLength = isset($config->Social->max_tag_length) - ? $config->Social->max_tag_length : 64; - return new \VuFind\Tags($maxLength); - } - /** * Construct the translator. * diff --git a/module/VuFind/src/VuFind/TagsFactory.php b/module/VuFind/src/VuFind/TagsFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..7ddcd7be79fa0a927db2835cc1706ec561dee5b3 --- /dev/null +++ b/module/VuFind/src/VuFind/TagsFactory.php @@ -0,0 +1,69 @@ +<?php +/** + * Tags 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 Tags + * @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; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + +/** + * Tags factory. + * + * @category VuFind + * @package Tags + * @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 TagsFactory 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.'); + } + $config = $container->get('VuFind\Config\PluginManager')->get('config'); + $maxLength = isset($config->Social->max_tag_length) + ? $config->Social->max_tag_length : 64; + return new $requestedName($maxLength); + } +}