From c210d82b35642081c8b16a0130d8f35af1941de8 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 21 Feb 2014 09:23:09 -0500 Subject: [PATCH] Finished elimination of closures from configs. --- module/VuFindTheme/Module.php | 45 ++----- .../src/VuFindTheme/View/Helper/Factory.php | 125 ++++++++++++++++++ 2 files changed, 138 insertions(+), 32 deletions(-) create mode 100644 module/VuFindTheme/src/VuFindTheme/View/Helper/Factory.php diff --git a/module/VuFindTheme/Module.php b/module/VuFindTheme/Module.php index 97a9c1eb530..74f908aa139 100644 --- a/module/VuFindTheme/Module.php +++ b/module/VuFindTheme/Module.php @@ -80,42 +80,23 @@ class Module */ public function getViewHelperConfig() { - // @codingStandardsIgnoreStart return array( 'factories' => array( - 'headlink' => function ($sm) { - return new \VuFindTheme\View\Helper\HeadLink( - $sm->getServiceLocator()->get('VuFindTheme\ThemeInfo') - ); - }, - 'headscript' => function ($sm) { - return new \VuFindTheme\View\Helper\HeadScript( - $sm->getServiceLocator()->get('VuFindTheme\ThemeInfo') - ); - }, - 'headthemeresources' => function ($sm) { - return new \VuFindTheme\View\Helper\HeadThemeResources( - $sm->getServiceLocator()->get('VuFindTheme\ResourceContainer') - ); - }, - 'imagelink' => function ($sm) { - return new \VuFindTheme\View\Helper\ImageLink( - $sm->getServiceLocator()->get('VuFindTheme\ThemeInfo') - ); - }, - 'inlinescript' => function ($sm) { - return new \VuFindTheme\View\Helper\InlineScript( - $sm->getServiceLocator()->get('VuFindTheme\ThemeInfo') - ); - }, - 'mobileurl' => function ($sm) { - return new \VuFindTheme\View\Helper\MobileUrl( - $sm->getServiceLocator()->get('VuFindTheme\Mobile') - ); - }, + 'headlink' => + array('VuFindTheme\View\Helper\Factory', 'getHeadLink'), + 'headscript' => + array('VuFindTheme\View\Helper\Factory', 'getHeadScript'), + 'headthemeresources' => array( + 'VuFindTheme\View\Helper\Factory', 'getHeadThemeResources' + ), + 'imagelink' => + array('VuFindTheme\View\Helper\Factory', 'getImageLink'), + 'inlinescript' => + array('VuFindTheme\View\Helper\Factory', 'getInlineScript'), + 'mobileurl' => + array('VuFindTheme\View\Helper\Factory', 'getMobileUrl'), ), ); - // @codingStandardsIgnoreEnd } /** diff --git a/module/VuFindTheme/src/VuFindTheme/View/Helper/Factory.php b/module/VuFindTheme/src/VuFindTheme/View/Helper/Factory.php new file mode 100644 index 00000000000..dfdcb382107 --- /dev/null +++ b/module/VuFindTheme/src/VuFindTheme/View/Helper/Factory.php @@ -0,0 +1,125 @@ +<?php +/** + * Factory for VuFindTheme view helpers. + * + * PHP version 5 + * + * Copyright (C) Villanova University 2014. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package VuDL + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/vufind2:developer_manual Wiki + */ +namespace VuFindTheme\View\Helper; +use Zend\ServiceManager\ServiceManager; + +/** + * Factory for VuFindTheme view helpers. + * + * @category VuFind2 + * @package VuDL + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/vufind2:developer_manual Wiki + */ +class Factory +{ + /** + * Construct the HeadLink helper. + * + * @param ServiceManager $sm Service manager. + * + * @return HeadLink + */ + public static function getHeadLink(ServiceManager $sm) + { + return new HeadLink( + $sm->getServiceLocator()->get('VuFindTheme\ThemeInfo') + ); + } + + /** + * Construct the HeadScript helper. + * + * @param ServiceManager $sm Service manager. + * + * @return HeadScript + */ + public static function getHeadScript(ServiceManager $sm) + { + return new HeadScript( + $sm->getServiceLocator()->get('VuFindTheme\ThemeInfo') + ); + } + + /** + * Construct the HeadThemeResources helper. + * + * @param ServiceManager $sm Service manager. + * + * @return HeadThemeResources + */ + public static function getHeadThemeResources(ServiceManager $sm) + { + return new HeadThemeResources( + $sm->getServiceLocator()->get('VuFindTheme\ResourceContainer') + ); + } + + /** + * Construct the ImageLink helper. + * + * @param ServiceManager $sm Service manager. + * + * @return ImageLink + */ + public static function getImageLink(ServiceManager $sm) + { + return new ImageLink( + $sm->getServiceLocator()->get('VuFindTheme\ThemeInfo') + ); + } + + /** + * Construct the InlineScript helper. + * + * @param ServiceManager $sm Service manager. + * + * @return InlineScript + */ + public static function getInlineScript(ServiceManager $sm) + { + return new InlineScript( + $sm->getServiceLocator()->get('VuFindTheme\ThemeInfo') + ); + } + + /** + * Construct the MobileUrl helper. + * + * @param ServiceManager $sm Service manager. + * + * @return MobileUrl + */ + public static function getMobileUrl(ServiceManager $sm) + { + return new MobileUrl( + $sm->getServiceLocator()->get('VuFindTheme\Mobile') + ); + } +} \ No newline at end of file -- GitLab