diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Config.php b/module/VuFind/src/VuFind/View/Helper/Root/Config.php new file mode 100644 index 0000000000000000000000000000000000000000..be59ab30500907039974564c6dc25e24556666f0 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/Config.php @@ -0,0 +1,71 @@ +<?php +/** + * Config view helper + * + * 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 View_Helpers + * @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\View\Helper\Root; + +use VuFind\Config\PluginManager; + +/** + * Config view helper + * + * @category VuFind + * @package View_Helpers + * @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 Config extends \Zend\View\Helper\AbstractHelper +{ + /** + * Configuration plugin manager + * + * @var PluginManager + */ + protected $configLoader; + + /** + * Constructor + * + * @param Helper $helper Capabilities helper + */ + public function __construct(PluginManager $configLoader) + { + $this->configLoader = $configLoader; + } + + /** + * Get the specified configuration. + * + * @param string $config Name of configuration + * + * @return \Zend\Config\Config + */ + public function get($config) + { + return $this->configLoader->get($config); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ConfigFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/ConfigFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..673325df9dafdf12acb88780a056108e32c3387c --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/ConfigFactory.php @@ -0,0 +1,66 @@ +<?php +/** + * Config helper 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 View_Helpers + * @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\View\Helper\Root; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + +/** + * Config helper factory. + * + * @category VuFind + * @package View_Helpers + * @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 ConfigFactory 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\Config\PluginManager')); + } +} diff --git a/themes/root/theme.config.php b/themes/root/theme.config.php index 4a27359a56425bae4b3a5fef2f0685e64f22fe5b..d6e8154204ce1c5a908f29ad51008020c93fe91c 100644 --- a/themes/root/theme.config.php +++ b/themes/root/theme.config.php @@ -12,6 +12,7 @@ return [ 'VuFind\View\Helper\Root\Browse' => 'Zend\ServiceManager\Factory\InvokableFactory', 'VuFind\View\Helper\Root\Cart' => 'VuFind\View\Helper\Root\Factory::getCart', 'VuFind\View\Helper\Root\Citation' => 'VuFind\View\Helper\Root\Factory::getCitation', + 'VuFind\View\Helper\Root\Config' => 'VuFind\View\Helper\Root\ConfigFactory', 'VuFind\View\Helper\Root\Context' => 'Zend\ServiceManager\Factory\InvokableFactory', 'VuFind\View\Helper\Root\CurrentPath' => 'Zend\ServiceManager\Factory\InvokableFactory', 'VuFind\View\Helper\Root\DateTime' => 'VuFind\View\Helper\Root\Factory::getDateTime', @@ -68,6 +69,7 @@ return [ 'browse' => 'VuFind\View\Helper\Root\Browse', 'cart' => 'VuFind\View\Helper\Root\Cart', 'citation' => 'VuFind\View\Helper\Root\Citation', + 'config' => 'VuFind\View\Helper\Root\Config', 'context' => 'VuFind\View\Helper\Root\Context', 'currentPath' => 'VuFind\View\Helper\Root\CurrentPath', 'dateTime' => 'VuFind\View\Helper\Root\DateTime',