From a48e9bb879639f455899a837f3976238b8381a18 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 17 May 2018 16:11:19 -0400 Subject: [PATCH] Eliminate static view helper factories (#1180) --- .../VuFind/View/Helper/Bootstrap3/Factory.php | 99 --- .../Helper/Bootstrap3/LayoutClassFactory.php | 77 +++ .../Root/AccountCapabilitiesFactory.php | 68 ++ .../View/Helper/Root/AddThisFactory.php | 67 ++ .../View/Helper/Root/AlphaBrowseFactory.php | 67 ++ .../VuFind/View/Helper/Root/AuthFactory.php | 69 ++ .../View/Helper/Root/AuthorNotesFactory.php | 69 ++ .../VuFind/View/Helper/Root/CartFactory.php | 66 ++ .../View/Helper/Root/CitationFactory.php | 66 ++ .../View/Helper/Root/ContentLoaderFactory.php | 70 ++ .../View/Helper/Root/DateTimeFactory.php | 66 ++ .../Root/DisplayLanguageOptionFactory.php | 71 ++ .../VuFind/View/Helper/Root/ExportFactory.php | 66 ++ .../src/VuFind/View/Helper/Root/Factory.php | 618 ------------------ .../View/Helper/Root/FeedbackFactory.php | 67 ++ .../View/Helper/Root/FlashmessagesFactory.php | 68 ++ .../View/Helper/Root/GeoCoordsFactory.php | 68 ++ .../Helper/Root/GoogleAnalyticsFactory.php | 69 ++ .../View/Helper/Root/HelpTextFactory.php | 70 ++ .../View/Helper/Root/HistoryLabelFactory.php | 70 ++ .../VuFind/View/Helper/Root/IlsFactory.php | 66 ++ .../Helper/Root/JsTranslationsFactory.php | 67 ++ .../View/Helper/Root/KeepAliveFactory.php | 67 ++ .../View/Helper/Root/OpenUrlFactory.php | 81 +++ .../View/Helper/Root/PermissionFactory.php | 69 ++ .../VuFind/View/Helper/Root/PiwikFactory.php | 75 +++ .../View/Helper/Root/ProxyUrlFactory.php | 67 ++ .../View/Helper/Root/RecaptchaFactory.php | 69 ++ .../VuFind/View/Helper/Root/RecordFactory.php | 69 ++ .../View/Helper/Root/RecordLinkFactory.php | 66 ++ .../View/Helper/Root/RelatedFactory.php | 66 ++ .../View/Helper/Root/ResultFeedFactory.php | 68 ++ .../Helper/Root/SafeMoneyFormatFactory.php | 68 ++ .../View/Helper/Root/SearchBoxFactory.php | 78 +++ .../View/Helper/Root/SearchMemoryFactory.php | 66 ++ .../View/Helper/Root/SearchOptionsFactory.php | 68 ++ .../View/Helper/Root/SearchParamsFactory.php | 68 ++ .../View/Helper/Root/SearchTabsFactory.php | 70 ++ .../View/Helper/Root/SyndeticsPlusFactory.php | 67 ++ .../View/Helper/Root/SystemEmailFactory.php | 67 ++ .../View/Helper/Root/UserListFactory.php | 69 ++ .../View/Helper/Root/UserTagsFactory.php | 67 ++ themes/bootstrap3/theme.config.php | 6 +- themes/root/theme.config.php | 78 +-- 44 files changed, 2794 insertions(+), 759 deletions(-) delete mode 100644 module/VuFind/src/VuFind/View/Helper/Bootstrap3/Factory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Bootstrap3/LayoutClassFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/AccountCapabilitiesFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/AddThisFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/AlphaBrowseFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/AuthFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/AuthorNotesFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/CartFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/CitationFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/ContentLoaderFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/DateTimeFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/DisplayLanguageOptionFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/ExportFactory.php delete mode 100644 module/VuFind/src/VuFind/View/Helper/Root/Factory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/FeedbackFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/FlashmessagesFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/GeoCoordsFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/GoogleAnalyticsFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/HelpTextFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/HistoryLabelFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/IlsFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/JsTranslationsFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/KeepAliveFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/OpenUrlFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/PermissionFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/PiwikFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/RecaptchaFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/RecordFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/RecordLinkFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/RelatedFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/ResultFeedFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/SafeMoneyFormatFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/SearchBoxFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/SearchMemoryFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/SearchOptionsFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/SearchParamsFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/SearchTabsFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/SyndeticsPlusFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/SystemEmailFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/UserListFactory.php create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/UserTagsFactory.php diff --git a/module/VuFind/src/VuFind/View/Helper/Bootstrap3/Factory.php b/module/VuFind/src/VuFind/View/Helper/Bootstrap3/Factory.php deleted file mode 100644 index 89a895908e3..00000000000 --- a/module/VuFind/src/VuFind/View/Helper/Bootstrap3/Factory.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php -/** - * Factory for Bootstrap view helpers. - * - * PHP version 7 - * - * 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., 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\Bootstrap3; - -use Zend\ServiceManager\ServiceManager; - -/** - * Factory for Bootstrap view helpers. - * - * @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 - * - * @codeCoverageIgnore - */ -class Factory -{ - /** - * Construct the Flashmessages helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Flashmessages - */ - public static function getFlashmessages(ServiceManager $sm) - { - $messenger = $sm->get('ControllerPluginManager') - ->get('Zend\Mvc\Plugin\FlashMessenger\FlashMessenger'); - return new Flashmessages($messenger); - } - - /** - * Construct the LayoutClass helper. - * - * @param ServiceManager $sm Service manager. - * - * @return LayoutClass - */ - public static function getLayoutClass(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager')->get('config'); - $sidebarOnLeft = !isset($config->Site->sidebarOnLeft) - ? false : $config->Site->sidebarOnLeft; - $mirror = !isset($config->Site->mirrorSidebarInRTL) - ? true : $config->Site->mirrorSidebarInRTL; - $offcanvas = !isset($config->Site->offcanvas) - ? false : $config->Site->offcanvas; - // The right-to-left setting is injected into the layout by the Bootstrapper; - // pull it back out here to avoid duplicate effort, then use it to apply - // the mirror setting appropriately. - $layout = $sm->get('ViewManager')->getViewModel(); - if ($layout->rtl && $mirror) { - $sidebarOnLeft = !$sidebarOnLeft; - } - return new LayoutClass($sidebarOnLeft, $offcanvas); - } - - /** - * Construct the Recaptcha helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Recaptcha - */ - public static function getRecaptcha(ServiceManager $sm) - { - return new Recaptcha( - $sm->get('VuFind\Service\ReCaptcha'), - $sm->get('VuFind\Config\PluginManager')->get('config') - ); - } -} diff --git a/module/VuFind/src/VuFind/View/Helper/Bootstrap3/LayoutClassFactory.php b/module/VuFind/src/VuFind/View/Helper/Bootstrap3/LayoutClassFactory.php new file mode 100644 index 00000000000..8703255b271 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Bootstrap3/LayoutClassFactory.php @@ -0,0 +1,77 @@ +<?php +/** + * LayoutClass helper factory. + * + * PHP version 7 + * + * 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\Bootstrap3; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + +/** + * LayoutClass 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 LayoutClassFactory 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'); + $sidebarOnLeft = $config->Site->sidebarOnLeft ?? false; + $mirror = $config->Site->mirrorSidebarInRTL ?? true; + $offcanvas = $config->Site->offcanvas ?? false; + // The right-to-left setting is injected into the layout by the Bootstrapper; + // pull it back out here to avoid duplicate effort, then use it to apply + // the mirror setting appropriately. + $layout = $container->get('ViewManager')->getViewModel(); + if ($layout->rtl && $mirror) { + $sidebarOnLeft = !$sidebarOnLeft; + } + return new $requestedName($sidebarOnLeft, $offcanvas); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/AccountCapabilitiesFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/AccountCapabilitiesFactory.php new file mode 100644 index 00000000000..f3f1bfc0052 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/AccountCapabilitiesFactory.php @@ -0,0 +1,68 @@ +<?php +/** + * AccountCapabilities helper factory. + * + * PHP version 7 + * + * 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; + +/** + * AccountCapabilities 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 AccountCapabilitiesFactory 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\AccountCapabilities') + ); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/AddThisFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/AddThisFactory.php new file mode 100644 index 00000000000..ec73c23d32b --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/AddThisFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * AddThis helper factory. + * + * PHP version 7 + * + * 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; + +/** + * AddThis 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 AddThisFactory 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'); + return new $requestedName($config->AddThis->key ?? false); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/AlphaBrowseFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/AlphaBrowseFactory.php new file mode 100644 index 00000000000..b80ad7d7015 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/AlphaBrowseFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * AlphaBrowse helper factory. + * + * PHP version 7 + * + * 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; + +/** + * AlphaBrowse 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 AlphaBrowseFactory 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.'); + } + $helpers = $container->get('ViewHelperManager'); + return new $requestedName($helpers->get('url')); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/AuthFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/AuthFactory.php new file mode 100644 index 00000000000..e90a0280cd3 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/AuthFactory.php @@ -0,0 +1,69 @@ +<?php +/** + * Auth helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Auth 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 AuthFactory 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\Auth\Manager'), + $container->get('VuFind\Auth\ILSAuthenticator') + ); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/AuthorNotesFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/AuthorNotesFactory.php new file mode 100644 index 00000000000..e90a0280cd3 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/AuthorNotesFactory.php @@ -0,0 +1,69 @@ +<?php +/** + * Auth helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Auth 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 AuthFactory 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\Auth\Manager'), + $container->get('VuFind\Auth\ILSAuthenticator') + ); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/CartFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/CartFactory.php new file mode 100644 index 00000000000..b9b69a13f99 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/CartFactory.php @@ -0,0 +1,66 @@ +<?php +/** + * Cart helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Cart 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 CartFactory 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\Cart')); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/CitationFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/CitationFactory.php new file mode 100644 index 00000000000..18a6a4b9a50 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/CitationFactory.php @@ -0,0 +1,66 @@ +<?php +/** + * Citation helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Citation 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 CitationFactory 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\Date\Converter')); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ContentLoaderFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/ContentLoaderFactory.php new file mode 100644 index 00000000000..fc4a74f8854 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/ContentLoaderFactory.php @@ -0,0 +1,70 @@ +<?php +/** + * ContentLoader helper factory. + * + * PHP version 7 + * + * 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; + +/** + * ContentLoader 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 ContentLoaderFactory 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.'); + } + // Use the requested service name to look up the appropriate content loader: + $parts = explode('\\', $requestedName); + $type = strtolower(array_pop($parts)); + $loader = $container->get('VuFind\Content\PluginManager')->get($type); + return new ContentLoader($loader); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/DateTimeFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/DateTimeFactory.php new file mode 100644 index 00000000000..f86154c1c95 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/DateTimeFactory.php @@ -0,0 +1,66 @@ +<?php +/** + * DateTime helper factory. + * + * PHP version 7 + * + * 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; + +/** + * DateTime 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 DateTimeFactory 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\Date\Converter')); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/DisplayLanguageOptionFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/DisplayLanguageOptionFactory.php new file mode 100644 index 00000000000..c5b0380e94b --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/DisplayLanguageOptionFactory.php @@ -0,0 +1,71 @@ +<?php +/** + * DisplayLanguageOption helper factory. + * + * PHP version 7 + * + * 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; + +/** + * DisplayLanguageOption 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 DisplayLanguageOptionFactory 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.'); + } + // We want to construct a separate translator instance for this helper, + // since it configures different language/locale than the core shared + // instance! + return new $requestedName( + \VuFind\Service\Factory::getTranslator($container) + ); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ExportFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/ExportFactory.php new file mode 100644 index 00000000000..f61d09e9205 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/ExportFactory.php @@ -0,0 +1,66 @@ +<?php +/** + * Export helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Export 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 ExportFactory 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\Export')); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Factory.php b/module/VuFind/src/VuFind/View/Helper/Root/Factory.php deleted file mode 100644 index 2b18e4130e1..00000000000 --- a/module/VuFind/src/VuFind/View/Helper/Root/Factory.php +++ /dev/null @@ -1,618 +0,0 @@ -<?php -/** - * Factory for Root view helpers. - * - * PHP version 7 - * - * 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., 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 Zend\ServiceManager\ServiceManager; - -/** - * Factory for Root view helpers. - * - * @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 - * - * @codeCoverageIgnore - */ -class Factory -{ - /** - * Construct the AddThis helper. - * - * @param ServiceManager $sm Service manager. - * - * @return AddThis - */ - public static function getAddThis(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager')->get('config'); - return new AddThis($config->AddThis->key ?? false); - } - - /** - * Construct the AccountCapabilities helper. - * - * @param ServiceManager $sm Service manager. - * - * @return AccountCapabilities - */ - public static function getAccountCapabilities(ServiceManager $sm) - { - return new AccountCapabilities( - $sm->get('VuFind\Config\AccountCapabilities') - ); - } - - /** - * Construct the AlphaBrowse helper. - * - * @param ServiceManager $sm Service manager. - * - * @return AlphaBrowse - */ - public static function getAlphaBrowse(ServiceManager $sm) - { - $helpers = $sm->get('ViewHelperManager'); - return new AlphaBrowse($helpers->get('url')); - } - - /** - * Construct the Auth helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Auth - */ - public static function getAuth(ServiceManager $sm) - { - return new Auth( - $sm->get('VuFind\Auth\Manager'), - $sm->get('VuFind\Auth\ILSAuthenticator') - ); - } - - /** - * Construct the AuthorNotes helper. - * - * @param ServiceManager $sm Service manager. - * - * @return AuthorNotes - */ - public static function getAuthorNotes(ServiceManager $sm) - { - $loader = $sm->get('VuFind\Content\PluginManager') - ->get('authornotes'); - return new ContentLoader($loader); - } - - /** - * Construct the Cart helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Cart - */ - public static function getCart(ServiceManager $sm) - { - return new Cart($sm->get('VuFind\Cart')); - } - - /** - * Construct the Citation helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Citation - */ - public static function getCitation(ServiceManager $sm) - { - return new Citation($sm->get('VuFind\Date\Converter')); - } - - /** - * Construct the DateTime helper. - * - * @param ServiceManager $sm Service manager. - * - * @return DateTime - */ - public static function getDateTime(ServiceManager $sm) - { - return new DateTime($sm->get('VuFind\Date\Converter')); - } - - /** - * Construct the DisplayLanguageOption helper. - * - * @param ServiceManager $sm Service manager. - * - * @return DisplayLanguageOption - */ - public static function getDisplayLanguageOption(ServiceManager $sm) - { - // We want to construct a separate translator instance for this helper, - // since it configures different language/locale than the core shared - // instance! - return new DisplayLanguageOption( - \VuFind\Service\Factory::getTranslator($sm) - ); - } - - /** - * Construct the Export helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Export - */ - public static function getExport(ServiceManager $sm) - { - return new Export($sm->get('VuFind\Export')); - } - - /** - * Construct the Feedback helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Feedback - */ - public static function getFeedback(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager')->get('config'); - $enabled = $config->Feedback->tab_enabled ?? false; - return new Feedback($enabled); - } - - /** - * Construct the Flashmessages helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Flashmessages - */ - public static function getFlashmessages(ServiceManager $sm) - { - $messenger = $sm->get('ControllerPluginManager') - ->get('Zend\Mvc\Plugin\FlashMessenger\FlashMessenger'); - return new Flashmessages($messenger); - } - - /** - * Construct the GeoCoords helper. - * - * @param ServiceManager $sm Service manager. - * - * @return GeoCoords - */ - public static function getGeoCoords(ServiceManager $sm) - { - $config = $sm->get('VuFind\GeoFeatures\MapSelectionConfig') - ->getMapSelectionOptions(); - return new GeoCoords($config['default_coordinates']); - } - - /** - * Construct the GoogleAnalytics helper. - * - * @param ServiceManager $sm Service manager. - * - * @return GoogleAnalytics - */ - public static function getGoogleAnalytics(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager')->get('config'); - $key = $config->GoogleAnalytics->apiKey ?? false; - $universal = $config->GoogleAnalytics->universal ?? false; - return new GoogleAnalytics($key, $universal); - } - - /** - * Construct the Permission helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Permission - */ - public static function getPermission(ServiceManager $sm) - { - $ld = new Permission( - $sm->get('VuFind\Role\PermissionManager'), - $sm->get('VuFind\Role\PermissionDeniedManager') - ); - return $ld; - } - - /** - * Construct the Piwik helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Piwik - */ - public static function getPiwik(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager')->get('config'); - $url = $config->Piwik->url ?? false; - $options = [ - 'siteId' => $config->Piwik->site_id ?? 1, - 'searchPrefix' => $config->Piwik->searchPrefix ?? null - ]; - $customVars = $config->Piwik->custom_variables ?? false; - $request = $sm->get('Request'); - $router = $sm->get('Router'); - return new Piwik($url, $options, $customVars, $router, $request); - } - - /** - * Construct the HelpText helper. - * - * @param ServiceManager $sm Service manager. - * - * @return HelpText - */ - public static function getHelpText(ServiceManager $sm) - { - $lang = $sm->has('Zend\Mvc\I18n\Translator') - ? $sm->get('Zend\Mvc\I18n\Translator')->getLocale() - : 'en'; - $helpers = $sm->get('ViewHelperManager'); - return new HelpText($helpers->get('context'), $lang); - } - - /** - * Construct the HistoryLabel helper. - * - * @param ServiceManager $sm Service manager. - * - * @return HistoryLabel - */ - public static function getHistoryLabel(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager')->get('config'); - $config = isset($config->SearchHistoryLabels) - ? $config->SearchHistoryLabels->toArray() : []; - $helpers = $sm->get('ViewHelperManager'); - return new HistoryLabel($config, $helpers->get('transEsc')); - } - - /** - * Construct the Ils helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Ils - */ - public static function getIls(ServiceManager $sm) - { - return new Ils($sm->get('VuFind\ILS\Connection')); - } - - /** - * Construct the JsTranslations helper. - * - * @param ServiceManager $sm Service manager. - * - * @return JsTranslations - */ - public static function getJsTranslations(ServiceManager $sm) - { - $helpers = $sm->get('ViewHelperManager'); - return new JsTranslations($helpers->get('transEsc')); - } - - /** - * Construct the KeepAlive helper. - * - * @param ServiceManager $sm Service manager. - * - * @return KeepAlive - */ - public static function getKeepAlive(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager')->get('config'); - return new KeepAlive($config->Session->keepAlive ?? 0); - } - - /** - * Construct the OpenUrl helper. - * - * @param ServiceManager $sm Service manager. - * - * @return OpenUrl - */ - public static function getOpenUrl(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager')->get('config'); - $openUrlRules = json_decode( - file_get_contents( - \VuFind\Config\Locator::getConfigPath('OpenUrlRules.json') - ), - true - ); - $resolverPluginManager = $sm - ->get('VuFind\Resolver\Driver\PluginManager'); - $helpers = $sm->get('ViewHelperManager'); - return new OpenUrl( - $helpers->get('context'), - $openUrlRules, - $resolverPluginManager, - $config->OpenURL ?? null - ); - } - - /** - * Construct the ProxyUrl helper. - * - * @param ServiceManager $sm Service manager. - * - * @return ProxyUrl - */ - public static function getProxyUrl(ServiceManager $sm) - { - return new ProxyUrl( - $sm->get('VuFind\Config\PluginManager')->get('config') - ); - } - - /** - * Construct the Recaptcha helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Recaptcha - */ - public static function getRecaptcha(ServiceManager $sm) - { - return new Recaptcha( - $sm->get('VuFind\Service\ReCaptcha'), - $sm->get('VuFind\Config\PluginManager')->get('config') - ); - } - - /** - * Construct the Record helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Record - */ - public static function getRecord(ServiceManager $sm) - { - $helper = new Record( - $sm->get('VuFind\Config\PluginManager')->get('config') - ); - $helper->setCoverRouter( - $sm->get('VuFind\Cover\Router') - ); - return $helper; - } - - /** - * Construct the RecordLink helper. - * - * @param ServiceManager $sm Service manager. - * - * @return RecordLink - */ - public static function getRecordLink(ServiceManager $sm) - { - return new RecordLink($sm->get('VuFind\Record\Router')); - } - - /** - * Construct the Related helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Related - */ - public static function getRelated(ServiceManager $sm) - { - return new Related($sm->get('VuFind\Related\PluginManager')); - } - - /** - * Construct the ResultFeed helper. - * - * @param ServiceManager $sm Service manager. - * - * @return ResultFeed - */ - public static function getResultFeed(ServiceManager $sm) - { - $helper = new ResultFeed(); - $helper->registerExtensions($sm); - return $helper; - } - - /** - * Construct the SafeMoneyFormat helper. - * - * @param ServiceManager $sm Service manager. - * - * @return SafeMoneyFormat - */ - public static function getSafeMoneyFormat(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager')->get('config'); - $defaultCurrency = $config->Site->defaultCurrency ?? null; - return new SafeMoneyFormat($defaultCurrency); - } - - /** - * Construct the SearchBox helper. - * - * @param ServiceManager $sm Service manager. - * - * @return SearchBox - */ - public static function getSearchBox(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager'); - $mainConfig = $config->get('config'); - $searchboxConfig = $config->get('searchbox')->toArray(); - $includeAlphaOptions - = $searchboxConfig['General']['includeAlphaBrowse'] ?? false; - return new SearchBox( - $sm->get('VuFind\Search\Options\PluginManager'), - $searchboxConfig, - isset($mainConfig->SearchPlaceholder) - ? $mainConfig->SearchPlaceholder->toArray() : [], - $includeAlphaOptions && isset($mainConfig->AlphaBrowse_Types) - ? $mainConfig->AlphaBrowse_Types->toArray() : [] - ); - } - - /** - * Construct the SearchMemory helper. - * - * @param ServiceManager $sm Service manager. - * - * @return SearchMemory - */ - public static function getSearchMemory(ServiceManager $sm) - { - return new SearchMemory( - $sm->get('VuFind\Search\Memory') - ); - } - - /** - * Construct the SearchOptions helper. - * - * @param ServiceManager $sm Service manager. - * - * @return SearchOptions - */ - public static function getSearchOptions(ServiceManager $sm) - { - return new SearchOptions( - $sm->get('VuFind\Search\Options\PluginManager') - ); - } - - /** - * Construct the SearchParams helper. - * - * @param ServiceManager $sm Service manager. - * - * @return SearchParams - */ - public static function getSearchParams(ServiceManager $sm) - { - return new SearchParams( - $sm->get('VuFind\Search\Params\PluginManager') - ); - } - - /** - * Construct the SearchTabs helper. - * - * @param ServiceManager $sm Service manager. - * - * @return SearchTabs - */ - public static function getSearchTabs(ServiceManager $sm) - { - $helpers = $sm->get('ViewHelperManager'); - return new SearchTabs( - $sm->get('VuFind\Search\Results\PluginManager'), - $helpers->get('url'), $sm->get('VuFind\Search\SearchTabsHelper') - ); - } - - /** - * Construct the Summary helper. - * - * @param ServiceManager $sm Service manager. - * - * @return Summaries - */ - public static function getSummaries(ServiceManager $sm) - { - $loader = $sm->get('VuFind\Content\PluginManager') - ->get('summaries'); - return new ContentLoader($loader); - } - - /** - * Construct the SyndeticsPlus helper. - * - * @param ServiceManager $sm Service manager. - * - * @return SyndeticsPlus - */ - public static function getSyndeticsPlus(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager')->get('config'); - return new SyndeticsPlus($config->Syndetics ?? null); - } - - /** - * Construct the SystemEmail helper. - * - * @param ServiceManager $sm Service manager. - * - * @return SystemEmail - */ - public static function getSystemEmail(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config\PluginManager')->get('config'); - return new SystemEmail($config->Site->email ?? ''); - } - - /** - * Construct the UserList helper. - * - * @param ServiceManager $sm Service manager. - * - * @return UserList - */ - public static function getUserList(ServiceManager $sm) - { - $sessionManager = $sm->get('Zend\Session\SessionManager'); - $session = new \Zend\Session\Container('List', $sessionManager); - $capabilities = $sm->get('VuFind\Config\AccountCapabilities'); - return new UserList($session, $capabilities->getListSetting()); - } - - /** - * Construct the UserTags helper. - * - * @param ServiceManager $sm Service manager. - * - * @return UserTags - */ - public static function getUserTags(ServiceManager $sm) - { - $capabilities = $sm->get('VuFind\Config\AccountCapabilities'); - return new UserTags($capabilities->getTagSetting()); - } -} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/FeedbackFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/FeedbackFactory.php new file mode 100644 index 00000000000..120bd276a05 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/FeedbackFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * Feedback helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Feedback 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 FeedbackFactory 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'); + return new $requestedName($config->Feedback->tab_enabled ?? false); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/FlashmessagesFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/FlashmessagesFactory.php new file mode 100644 index 00000000000..bcd67fff84f --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/FlashmessagesFactory.php @@ -0,0 +1,68 @@ +<?php +/** + * Flashmessages helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Flashmessages 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 FlashmessagesFactory 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.'); + } + $messenger = $container->get('ControllerPluginManager') + ->get('Zend\Mvc\Plugin\FlashMessenger\FlashMessenger'); + return new $requestedName($messenger); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/GeoCoordsFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/GeoCoordsFactory.php new file mode 100644 index 00000000000..5627bdf90df --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/GeoCoordsFactory.php @@ -0,0 +1,68 @@ +<?php +/** + * GeoCoords helper factory. + * + * PHP version 7 + * + * 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; + +/** + * GeoCoords 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 GeoCoordsFactory 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\GeoFeatures\MapSelectionConfig') + ->getMapSelectionOptions(); + return new $requestedName($config['default_coordinates']); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/GoogleAnalyticsFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/GoogleAnalyticsFactory.php new file mode 100644 index 00000000000..0d63b823b6a --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/GoogleAnalyticsFactory.php @@ -0,0 +1,69 @@ +<?php +/** + * GoogleAnalytics helper factory. + * + * PHP version 7 + * + * 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; + +/** + * GoogleAnalytics 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 GoogleAnalyticsFactory 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'); + $key = $config->GoogleAnalytics->apiKey ?? false; + $universal = $config->GoogleAnalytics->universal ?? false; + return new $requestedName($key, $universal); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/HelpTextFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/HelpTextFactory.php new file mode 100644 index 00000000000..218894eec93 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/HelpTextFactory.php @@ -0,0 +1,70 @@ +<?php +/** + * HelpText helper factory. + * + * PHP version 7 + * + * 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; + +/** + * HelpText 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 HelpTextFactory 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.'); + } + $lang = $container->has('Zend\Mvc\I18n\Translator') + ? $container->get('Zend\Mvc\I18n\Translator')->getLocale() + : 'en'; + $helpers = $container->get('ViewHelperManager'); + return new $requestedName($helpers->get('context'), $lang); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/HistoryLabelFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/HistoryLabelFactory.php new file mode 100644 index 00000000000..b41a08cf1d0 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/HistoryLabelFactory.php @@ -0,0 +1,70 @@ +<?php +/** + * HistoryLabel helper factory. + * + * PHP version 7 + * + * 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; + +/** + * HistoryLabel 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 HistoryLabelFactory 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'); + $labels = isset($config->SearchHistoryLabels) + ? $config->SearchHistoryLabels->toArray() : []; + $helpers = $container->get('ViewHelperManager'); + return new $requestedName($labels, $helpers->get('transEsc')); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/IlsFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/IlsFactory.php new file mode 100644 index 00000000000..b83f818ee9c --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/IlsFactory.php @@ -0,0 +1,66 @@ +<?php +/** + * Ils helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Ils 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 IlsFactory 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\ILS\Connection')); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/JsTranslationsFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/JsTranslationsFactory.php new file mode 100644 index 00000000000..21a21e565d9 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/JsTranslationsFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * JsTranslations helper factory. + * + * PHP version 7 + * + * 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; + +/** + * JsTranslations 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 JsTranslationsFactory 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.'); + } + $helpers = $container->get('ViewHelperManager'); + return new $requestedName($helpers->get('transEsc')); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/KeepAliveFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/KeepAliveFactory.php new file mode 100644 index 00000000000..603b351ce93 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/KeepAliveFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * KeepAlive helper factory. + * + * PHP version 7 + * + * 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; + +/** + * KeepAlive 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 KeepAliveFactory 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'); + return new $requestedName($config->Session->keepAlive ?? 0); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/OpenUrlFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/OpenUrlFactory.php new file mode 100644 index 00000000000..fc3ed6bd875 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/OpenUrlFactory.php @@ -0,0 +1,81 @@ +<?php +/** + * OpenUrl helper factory. + * + * PHP version 7 + * + * 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; + +/** + * OpenUrl 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 OpenUrlFactory 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'); + $openUrlRules = json_decode( + file_get_contents( + \VuFind\Config\Locator::getConfigPath('OpenUrlRules.json') + ), + true + ); + $resolverPluginManager + = $container->get('VuFind\Resolver\Driver\PluginManager'); + $helpers = $container->get('ViewHelperManager'); + return new $requestedName( + $helpers->get('context'), + $openUrlRules, + $resolverPluginManager, + $config->OpenURL ?? null + ); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/PermissionFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/PermissionFactory.php new file mode 100644 index 00000000000..8b17ded2230 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/PermissionFactory.php @@ -0,0 +1,69 @@ +<?php +/** + * Permission helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Permission 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 PermissionFactory 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\Role\PermissionManager'), + $container->get('VuFind\Role\PermissionDeniedManager') + ); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/PiwikFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/PiwikFactory.php new file mode 100644 index 00000000000..27fcd3dfd85 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/PiwikFactory.php @@ -0,0 +1,75 @@ +<?php +/** + * Piwik helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Piwik 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 PiwikFactory 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'); + $url = $config->Piwik->url ?? false; + $settings = [ + 'siteId' => $config->Piwik->site_id ?? 1, + 'searchPrefix' => $config->Piwik->searchPrefix ?? null + ]; + $customVars = $config->Piwik->custom_variables ?? false; + $request = $container->get('Request'); + $router = $container->get('Router'); + return new $requestedName($url, $settings, $customVars, $router, $request); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php new file mode 100644 index 00000000000..ea007570fe1 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * ProxyUrl helper factory. + * + * PHP version 7 + * + * 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; + +/** + * ProxyUrl 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 ProxyUrlFactory 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'); + return new $requestedName($config); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/RecaptchaFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/RecaptchaFactory.php new file mode 100644 index 00000000000..411d01e06db --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/RecaptchaFactory.php @@ -0,0 +1,69 @@ +<?php +/** + * Recaptcha helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Recaptcha 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 RecaptchaFactory 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\Service\ReCaptcha'), + $container->get('VuFind\Config\PluginManager')->get('config') + ); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/RecordFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/RecordFactory.php new file mode 100644 index 00000000000..5ae8ecde63f --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/RecordFactory.php @@ -0,0 +1,69 @@ +<?php +/** + * Record helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Record 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 RecordFactory 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'); + $helper = new $requestedName($config); + $helper->setCoverRouter($container->get('VuFind\Cover\Router')); + return $helper; + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/RecordLinkFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/RecordLinkFactory.php new file mode 100644 index 00000000000..c3260932137 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/RecordLinkFactory.php @@ -0,0 +1,66 @@ +<?php +/** + * RecordLink helper factory. + * + * PHP version 7 + * + * 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; + +/** + * RecordLink 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 RecordLinkFactory 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\Record\Router')); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/RelatedFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/RelatedFactory.php new file mode 100644 index 00000000000..33146f1e3d5 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/RelatedFactory.php @@ -0,0 +1,66 @@ +<?php +/** + * Related helper factory. + * + * PHP version 7 + * + * 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; + +/** + * Related 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 RelatedFactory 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\Related\PluginManager')); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ResultFeedFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/ResultFeedFactory.php new file mode 100644 index 00000000000..fe044576542 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/ResultFeedFactory.php @@ -0,0 +1,68 @@ +<?php +/** + * ResultFeed helper factory. + * + * PHP version 7 + * + * 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; + +/** + * ResultFeed 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 ResultFeedFactory 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.'); + } + $helper = new $requestedName(); + $helper->registerExtensions($container); + return $helper; + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SafeMoneyFormatFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/SafeMoneyFormatFactory.php new file mode 100644 index 00000000000..d84fef199fe --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/SafeMoneyFormatFactory.php @@ -0,0 +1,68 @@ +<?php +/** + * SafeMoneyFormat helper factory. + * + * PHP version 7 + * + * 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; + +/** + * SafeMoneyFormat 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 SafeMoneyFormatFactory 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'); + $defaultCurrency = $config->Site->defaultCurrency ?? null; + return new $requestedName($defaultCurrency); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SearchBoxFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/SearchBoxFactory.php new file mode 100644 index 00000000000..76edeb356aa --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/SearchBoxFactory.php @@ -0,0 +1,78 @@ +<?php +/** + * SearchBox helper factory. + * + * PHP version 7 + * + * 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; + +/** + * SearchBox 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 SearchBoxFactory 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'); + $mainConfig = $config->get('config'); + $searchboxConfig = $config->get('searchbox')->toArray(); + $includeAlphaOptions + = $searchboxConfig['General']['includeAlphaBrowse'] ?? false; + return new $requestedName( + $container->get('VuFind\Search\Options\PluginManager'), + $searchboxConfig, + isset($mainConfig->SearchPlaceholder) + ? $mainConfig->SearchPlaceholder->toArray() : [], + $includeAlphaOptions && isset($mainConfig->AlphaBrowse_Types) + ? $mainConfig->AlphaBrowse_Types->toArray() : [] + ); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SearchMemoryFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/SearchMemoryFactory.php new file mode 100644 index 00000000000..a4ca1a90c4b --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/SearchMemoryFactory.php @@ -0,0 +1,66 @@ +<?php +/** + * SearchMemory helper factory. + * + * PHP version 7 + * + * 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; + +/** + * SearchMemory 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 SearchMemoryFactory 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\Search\Memory')); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SearchOptionsFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/SearchOptionsFactory.php new file mode 100644 index 00000000000..cf3deccbc2e --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/SearchOptionsFactory.php @@ -0,0 +1,68 @@ +<?php +/** + * SearchOptions helper factory. + * + * PHP version 7 + * + * 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; + +/** + * SearchOptions 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 SearchOptionsFactory 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\Search\Options\PluginManager') + ); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SearchParamsFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/SearchParamsFactory.php new file mode 100644 index 00000000000..73b6584b26e --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/SearchParamsFactory.php @@ -0,0 +1,68 @@ +<?php +/** + * SearchParams helper factory. + * + * PHP version 7 + * + * 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; + +/** + * SearchParams 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 SearchParamsFactory 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\Search\Params\PluginManager') + ); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SearchTabsFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/SearchTabsFactory.php new file mode 100644 index 00000000000..f8acf7e416d --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/SearchTabsFactory.php @@ -0,0 +1,70 @@ +<?php +/** + * SearchTabs helper factory. + * + * PHP version 7 + * + * 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; + +/** + * SearchTabs 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 SearchTabsFactory 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\Search\Results\PluginManager'), + $container->get('ViewHelperManager')->get('url'), + $container->get('VuFind\Search\SearchTabsHelper') + ); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SyndeticsPlusFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/SyndeticsPlusFactory.php new file mode 100644 index 00000000000..1ac1eb26d59 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/SyndeticsPlusFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * SyndeticsPlus helper factory. + * + * PHP version 7 + * + * 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; + +/** + * SyndeticsPlus 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 SyndeticsPlusFactory 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'); + return new $requestedName($config->Syndetics ?? null); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SystemEmailFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/SystemEmailFactory.php new file mode 100644 index 00000000000..832f79140c6 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/SystemEmailFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * SystemEmail helper factory. + * + * PHP version 7 + * + * 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; + +/** + * SystemEmail 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 SystemEmailFactory 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'); + return new $requestedName($config->Site->email ?? ''); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/UserListFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/UserListFactory.php new file mode 100644 index 00000000000..584c20ad928 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/UserListFactory.php @@ -0,0 +1,69 @@ +<?php +/** + * UserList helper factory. + * + * PHP version 7 + * + * 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; + +/** + * UserList 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 UserListFactory 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.'); + } + $sessionManager = $container->get('Zend\Session\SessionManager'); + $session = new \Zend\Session\Container('List', $sessionManager); + $capabilities = $container->get('VuFind\Config\AccountCapabilities'); + return new $requestedName($session, $capabilities->getListSetting()); + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/UserTagsFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/UserTagsFactory.php new file mode 100644 index 00000000000..c7ba6c028b1 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/UserTagsFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * UserTags helper factory. + * + * PHP version 7 + * + * 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; + +/** + * UserTags 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 UserTagsFactory 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.'); + } + $capabilities = $container->get('VuFind\Config\AccountCapabilities'); + return new $requestedName($capabilities->getTagSetting()); + } +} diff --git a/themes/bootstrap3/theme.config.php b/themes/bootstrap3/theme.config.php index 15d04646a78..733dd1aa5cb 100644 --- a/themes/bootstrap3/theme.config.php +++ b/themes/bootstrap3/theme.config.php @@ -27,10 +27,10 @@ return [ 'favicon' => 'vufind-favicon.ico', 'helpers' => [ 'factories' => [ - 'VuFind\View\Helper\Bootstrap3\Flashmessages' => 'VuFind\View\Helper\Bootstrap3\Factory::getFlashmessages', + 'VuFind\View\Helper\Bootstrap3\Flashmessages' => 'VuFind\View\Helper\Root\FlashmessagesFactory', 'VuFind\View\Helper\Bootstrap3\Highlight' => 'Zend\ServiceManager\Factory\InvokableFactory', - 'VuFind\View\Helper\Bootstrap3\LayoutClass' => 'VuFind\View\Helper\Bootstrap3\Factory::getLayoutClass', - 'VuFind\View\Helper\Bootstrap3\Recaptcha' => 'VuFind\View\Helper\Bootstrap3\Factory::getRecaptcha', + 'VuFind\View\Helper\Bootstrap3\LayoutClass' => 'VuFind\View\Helper\Bootstrap3\LayoutClassFactory', + 'VuFind\View\Helper\Bootstrap3\Recaptcha' => 'VuFind\View\Helper\Root\RecaptchaFactory', 'VuFind\View\Helper\Bootstrap3\Search' => 'Zend\ServiceManager\Factory\InvokableFactory', ], 'aliases' => [ diff --git a/themes/root/theme.config.php b/themes/root/theme.config.php index a479ee24ea1..d175736cfc7 100644 --- a/themes/root/theme.config.php +++ b/themes/root/theme.config.php @@ -3,63 +3,63 @@ return [ 'extends' => false, 'helpers' => [ 'factories' => [ - 'VuFind\View\Helper\Root\AccountCapabilities' => 'VuFind\View\Helper\Root\Factory::getAccountCapabilities', + 'VuFind\View\Helper\Root\AccountCapabilities' => 'VuFind\View\Helper\Root\AccountCapabilitiesFactory', 'VuFind\View\Helper\Root\AddEllipsis' => 'Zend\ServiceManager\Factory\InvokableFactory', - 'VuFind\View\Helper\Root\AddThis' => 'VuFind\View\Helper\Root\Factory::getAddThis', - 'VuFind\View\Helper\Root\AlphaBrowse' => 'VuFind\View\Helper\Root\Factory::getAlphaBrowse', - 'VuFind\View\Helper\Root\Auth' => 'VuFind\View\Helper\Root\Factory::getAuth', - 'VuFind\View\Helper\Root\AuthorNotes' => 'VuFind\View\Helper\Root\Factory::getAuthorNotes', + 'VuFind\View\Helper\Root\AddThis' => 'VuFind\View\Helper\Root\AddThisFactory', + 'VuFind\View\Helper\Root\AlphaBrowse' => 'VuFind\View\Helper\Root\AlphaBrowseFactory', + 'VuFind\View\Helper\Root\Auth' => 'VuFind\View\Helper\Root\AuthFactory', + 'VuFind\View\Helper\Root\AuthorNotes' => 'VuFind\View\Helper\Root\ContentLoaderFactory', '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\Cart' => 'VuFind\View\Helper\Root\CartFactory', + 'VuFind\View\Helper\Root\Citation' => 'VuFind\View\Helper\Root\CitationFactory', 'VuFind\View\Helper\Root\Config' => 'VuFind\View\Helper\Root\ConfigFactory', 'VuFind\View\Helper\Root\ContentBlock' => 'Zend\ServiceManager\Factory\InvokableFactory', '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', - 'VuFind\View\Helper\Root\DisplayLanguageOption' => 'VuFind\View\Helper\Root\Factory::getDisplayLanguageOption', - 'VuFind\View\Helper\Root\Export' => 'VuFind\View\Helper\Root\Factory::getExport', - 'VuFind\View\Helper\Root\Feedback' => 'VuFind\View\Helper\Root\Factory::getFeedback', - 'VuFind\View\Helper\Root\Flashmessages' => 'VuFind\View\Helper\Root\Factory::getFlashmessages', - 'VuFind\View\Helper\Root\GeoCoords' => 'VuFind\View\Helper\Root\Factory::getGeoCoords', - 'VuFind\View\Helper\Root\GoogleAnalytics' => 'VuFind\View\Helper\Root\Factory::getGoogleAnalytics', - 'VuFind\View\Helper\Root\HelpText' => 'VuFind\View\Helper\Root\Factory::getHelpText', + 'VuFind\View\Helper\Root\DateTime' => 'VuFind\View\Helper\Root\DateTimeFactory', + 'VuFind\View\Helper\Root\DisplayLanguageOption' => 'VuFind\View\Helper\Root\DisplayLanguageOptionFactory', + 'VuFind\View\Helper\Root\Export' => 'VuFind\View\Helper\Root\ExportFactory', + 'VuFind\View\Helper\Root\Feedback' => 'VuFind\View\Helper\Root\FeedbackFactory', + 'VuFind\View\Helper\Root\Flashmessages' => 'VuFind\View\Helper\Root\FlashmessagesFactory', + 'VuFind\View\Helper\Root\GeoCoords' => 'VuFind\View\Helper\Root\GeoCoordsFactory', + 'VuFind\View\Helper\Root\GoogleAnalytics' => 'VuFind\View\Helper\Root\GoogleAnalyticsFactory', + 'VuFind\View\Helper\Root\HelpText' => 'VuFind\View\Helper\Root\HelpTextFactory', 'VuFind\View\Helper\Root\Highlight' => 'Zend\ServiceManager\Factory\InvokableFactory', - 'VuFind\View\Helper\Root\HistoryLabel' => 'VuFind\View\Helper\Root\Factory::getHistoryLabel', - 'VuFind\View\Helper\Root\Ils' => 'VuFind\View\Helper\Root\Factory::getIls', - 'VuFind\View\Helper\Root\JsTranslations' => 'VuFind\View\Helper\Root\Factory::getJsTranslations', - 'VuFind\View\Helper\Root\KeepAlive' => 'VuFind\View\Helper\Root\Factory::getKeepAlive', + 'VuFind\View\Helper\Root\HistoryLabel' => 'VuFind\View\Helper\Root\HistoryLabelFactory', + 'VuFind\View\Helper\Root\Ils' => 'VuFind\View\Helper\Root\IlsFactory', + 'VuFind\View\Helper\Root\JsTranslations' => 'VuFind\View\Helper\Root\JsTranslationsFactory', + 'VuFind\View\Helper\Root\KeepAlive' => 'VuFind\View\Helper\Root\KeepAliveFactory', 'VuFind\View\Helper\Root\LocalizedNumber' => 'Zend\ServiceManager\Factory\InvokableFactory', - 'VuFind\View\Helper\Root\OpenUrl' => 'VuFind\View\Helper\Root\Factory::getOpenUrl', - 'VuFind\View\Helper\Root\Permission' => 'VuFind\View\Helper\Root\Factory::getPermission', - 'VuFind\View\Helper\Root\Piwik' => 'VuFind\View\Helper\Root\Factory::getPiwik', + 'VuFind\View\Helper\Root\OpenUrl' => 'VuFind\View\Helper\Root\OpenUrlFactory', + 'VuFind\View\Helper\Root\Permission' => 'VuFind\View\Helper\Root\PermissionFactory', + 'VuFind\View\Helper\Root\Piwik' => 'VuFind\View\Helper\Root\PiwikFactory', 'VuFind\View\Helper\Root\Printms' => 'Zend\ServiceManager\Factory\InvokableFactory', - 'VuFind\View\Helper\Root\ProxyUrl' => 'VuFind\View\Helper\Root\Factory::getProxyUrl', - 'VuFind\View\Helper\Root\Recaptcha' => 'VuFind\View\Helper\Root\Factory::getRecaptcha', + 'VuFind\View\Helper\Root\ProxyUrl' => 'VuFind\View\Helper\Root\ProxyUrlFactory', + 'VuFind\View\Helper\Root\Recaptcha' => 'VuFind\View\Helper\Root\RecaptchaFactory', 'VuFind\View\Helper\Root\Recommend' => 'Zend\ServiceManager\Factory\InvokableFactory', - 'VuFind\View\Helper\Root\Record' => 'VuFind\View\Helper\Root\Factory::getRecord', + 'VuFind\View\Helper\Root\Record' => 'VuFind\View\Helper\Root\RecordFactory', 'VuFind\View\Helper\Root\RecordDataFormatter' => 'VuFind\View\Helper\Root\RecordDataFormatterFactory', - 'VuFind\View\Helper\Root\RecordLink' => 'VuFind\View\Helper\Root\Factory::getRecordLink', + 'VuFind\View\Helper\Root\RecordLink' => 'VuFind\View\Helper\Root\RecordLinkFactory', 'VuFind\View\Helper\Root\Relais' => 'VuFind\View\Helper\Root\RelaisFactory', - 'VuFind\View\Helper\Root\Related' => 'VuFind\View\Helper\Root\Factory::getRelated', + 'VuFind\View\Helper\Root\Related' => 'VuFind\View\Helper\Root\RelatedFactory', 'VuFind\View\Helper\Root\RenderArray' => 'Zend\ServiceManager\Factory\InvokableFactory', - 'VuFind\View\Helper\Root\ResultFeed' => 'VuFind\View\Helper\Root\Factory::getResultFeed', - 'VuFind\View\Helper\Root\SafeMoneyFormat' => 'VuFind\View\Helper\Root\Factory::getSafeMoneyFormat', - 'VuFind\View\Helper\Root\SearchBox' => 'VuFind\View\Helper\Root\Factory::getSearchBox', - 'VuFind\View\Helper\Root\SearchMemory' => 'VuFind\View\Helper\Root\Factory::getSearchMemory', - 'VuFind\View\Helper\Root\SearchOptions' => 'VuFind\View\Helper\Root\Factory::getSearchOptions', - 'VuFind\View\Helper\Root\SearchParams' => 'VuFind\View\Helper\Root\Factory::getSearchParams', - 'VuFind\View\Helper\Root\SearchTabs' => 'VuFind\View\Helper\Root\Factory::getSearchTabs', + 'VuFind\View\Helper\Root\ResultFeed' => 'VuFind\View\Helper\Root\ResultFeedFactory', + 'VuFind\View\Helper\Root\SafeMoneyFormat' => 'VuFind\View\Helper\Root\SafeMoneyFormatFactory', + 'VuFind\View\Helper\Root\SearchBox' => 'VuFind\View\Helper\Root\SearchBoxFactory', + 'VuFind\View\Helper\Root\SearchMemory' => 'VuFind\View\Helper\Root\SearchMemoryFactory', + 'VuFind\View\Helper\Root\SearchOptions' => 'VuFind\View\Helper\Root\SearchOptionsFactory', + 'VuFind\View\Helper\Root\SearchParams' => 'VuFind\View\Helper\Root\SearchParamsFactory', + 'VuFind\View\Helper\Root\SearchTabs' => 'VuFind\View\Helper\Root\SearchTabsFactory', 'VuFind\View\Helper\Root\SortFacetList' => 'Zend\ServiceManager\Factory\InvokableFactory', - 'VuFind\View\Helper\Root\Summaries' => 'VuFind\View\Helper\Root\Factory::getSummaries', + 'VuFind\View\Helper\Root\Summaries' => 'VuFind\View\Helper\Root\ContentLoaderFactory', 'VuFind\View\Helper\Root\Summon' => 'Zend\ServiceManager\Factory\InvokableFactory', - 'VuFind\View\Helper\Root\SyndeticsPlus' => 'VuFind\View\Helper\Root\Factory::getSyndeticsPlus', - 'VuFind\View\Helper\Root\SystemEmail' => 'VuFind\View\Helper\Root\Factory::getSystemEmail', + 'VuFind\View\Helper\Root\SyndeticsPlus' => 'VuFind\View\Helper\Root\SyndeticsPlusFactory', + 'VuFind\View\Helper\Root\SystemEmail' => 'VuFind\View\Helper\Root\SystemEmailFactory', 'VuFind\View\Helper\Root\TransEsc' => 'Zend\ServiceManager\Factory\InvokableFactory', 'VuFind\View\Helper\Root\Translate' => 'Zend\ServiceManager\Factory\InvokableFactory', 'VuFind\View\Helper\Root\Truncate' => 'Zend\ServiceManager\Factory\InvokableFactory', - 'VuFind\View\Helper\Root\UserList' => 'VuFind\View\Helper\Root\Factory::getUserList', - 'VuFind\View\Helper\Root\UserTags' => 'VuFind\View\Helper\Root\Factory::getUserTags', + 'VuFind\View\Helper\Root\UserList' => 'VuFind\View\Helper\Root\UserListFactory', + 'VuFind\View\Helper\Root\UserTags' => 'VuFind\View\Helper\Root\UserTagsFactory', ], 'aliases' => [ 'accountCapabilities' => 'VuFind\View\Helper\Root\AccountCapabilities', -- GitLab