Skip to content
Snippets Groups Projects
Commit 5f15e13f authored by Demian Katz's avatar Demian Katz
Browse files

Add Config view helper.

parent 0c4f79af
No related merge requests found
<?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);
}
}
<?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'));
}
}
......@@ -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',
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment