diff --git a/module/fid/src/Listener/ClientConfigListener.php b/module/fid/src/Listener/ClientConfigListener.php index 4933f652946e274b5afff46958fcf4e0c3d96022..5945d1bdf9157d9925f39d919910441e65aec2e9 100644 --- a/module/fid/src/Listener/ClientConfigListener.php +++ b/module/fid/src/Listener/ClientConfigListener.php @@ -1,7 +1,11 @@ <?php /** + * Fidis client config listener + * * Copyright (C) 2020 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,8 +19,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Listener + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Listener; @@ -30,6 +37,15 @@ use Zend\EventManager\EventManagerInterface; use Zend\Mvc\MvcEvent; use Zend\View\Model\ViewModel; +/** + * Fidis client config listener + * + * @category VuFind + * @package Listener + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class ClientConfigListener extends AbstractListenerAggregate { protected const PARAM = 'fidis_base_url'; @@ -42,12 +58,12 @@ class ClientConfigListener extends AbstractListenerAggregate protected const STATUS = '%sFidis: %s'; - /** - * @var array - */ + /* @var array */ protected $config; /** + * Get configuration + * * @return array */ public function getConfig(): array @@ -55,23 +71,32 @@ class ClientConfigListener extends AbstractListenerAggregate return $this->config; } + /** + * Attach onDispatch method to event (MvcEvent::EVENT_ROUTE) + * + * @param EventManagerInterface $events Event manager + * @param $priority Used priority + * + * @return void + */ public function attach(EventManagerInterface $events, $priority = 9000) { $events->attach(static::EVENT, [$this, 'onDispatch'], $priority); } /** - * @param MvcEvent $event + * Handling fidis base url update via GET parameter (if allowed in config) + * + * @param MvcEvent $event Event * + * @return void * @throws ClientException */ public function onDispatch(MvcEvent $event) { - /** - * @var Config $config - * @var PluginManager $configManager - * @var ContainerInterface $container - */ + /* @var Config $config */ + /* @var PluginManager $configManager */ + /* @var ContainerInterface $container */ $request = $event->getRequest(); $container = $event->getApplication()->getServiceManager(); $configManager = $container->get(PluginManager::class); @@ -98,10 +123,8 @@ class ClientConfigListener extends AbstractListenerAggregate $baseUrl = $config->baseUrl; } - /** - * @var ViewModel $viewModel - * @var CookieManager $cookieManager - */ + /* @var ViewModel $viewModel */ + /* @var CookieManager $cookieManager */ $this->config['baseUrl'] = $baseUrl; $cookieManager = $container->get(CookieManager::class); $cookieManager->set(self::PARAM, $baseUrl); diff --git a/module/fid/src/Listener/ErrorListener.php b/module/fid/src/Listener/ErrorListener.php index 6b68145f75eedc70b151fef1fb4d554b16b1ab12..19a136d87d89c97bdb03b3a8c0f224a20027c705 100644 --- a/module/fid/src/Listener/ErrorListener.php +++ b/module/fid/src/Listener/ErrorListener.php @@ -1,7 +1,11 @@ <?php /** + * Error listener + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,16 +19,29 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Listener + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Listener; use Zend\EventManager\AbstractListenerAggregate; use Zend\EventManager\EventInterface; use Zend\EventManager\EventManagerInterface; +use Zend\Log\Filter\Priority; use Zend\Mvc\MvcEvent; +/** + * Error listener + * + * @category VuFind + * @package Listener + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class ErrorListener extends AbstractListenerAggregate { protected const ERROR_EVENTS @@ -33,6 +50,15 @@ class ErrorListener extends AbstractListenerAggregate MvcEvent::EVENT_RENDER_ERROR, ]; + /** + * Attach onError method to events: + * MvcEvent::EVENT_DISPATCH_ERROR and MvcEvent::EVENT_RENDER_ERROR + * + * @param EventManagerInterface $events Event manager + * @param $priority Used priority + * + * @return void + */ public function attach(EventManagerInterface $events, $priority = 20000) { foreach (static::ERROR_EVENTS as $event) { @@ -41,7 +67,11 @@ class ErrorListener extends AbstractListenerAggregate } /** - * @param EventInterface|MvcEvent $event + * On error event handling + * + * @param EventInterface|MvcEvent $event Event + * + * @return void */ public function onError(EventInterface $event): void { diff --git a/module/fid/src/Listener/LocaleListener.php b/module/fid/src/Listener/LocaleListener.php index 3634bf9813f9dbc8551d05975db0608769df81ca..48c97fa4d6a8afa911374752afd727c92631394a 100644 --- a/module/fid/src/Listener/LocaleListener.php +++ b/module/fid/src/Listener/LocaleListener.php @@ -1,7 +1,11 @@ <?php /** + * Locale listener + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,35 +19,58 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Listener + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Listener; use fid\Service\Client; use Zend\EventManager\AbstractListenerAggregate; use Zend\EventManager\EventManagerInterface; +use Zend\Log\Filter\Priority; use Zend\Mvc\I18n\Translator; use Zend\Mvc\MvcEvent; +/** + * Locale listener + * + * @category VuFind + * @package Listener + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class LocaleListener extends AbstractListenerAggregate { protected const EVENT = MvcEvent::EVENT_DISPATCH; + /** + * Attach onDispatch method to event (MvcEvent::EVENT_DISPATCH) + * + * @param EventManagerInterface $events Event manager + * @param $priority Used priority + * + * @return void + */ public function attach(EventManagerInterface $events, $priority = 9000) { $events->attach(static::EVENT, [$this, 'onDispatch'], $priority); } /** - * @param MvcEvent $event + * Set fidis clients locale + * + * @param MvcEvent $event Event + * + * @return void */ public function onDispatch(MvcEvent $event) { $container = $event->getApplication()->getServiceManager(); - /** - * @var Client $client - */ + /* @var Client $client */ $client = $container->get(Client::class); $locale = $container->get(Translator::class)->getLocale(); $client->setLocale($locale);