diff --git a/module/VuFind/src/VuFind/ChannelProvider/AlphaBrowseFactory.php b/module/VuFind/src/VuFind/ChannelProvider/AlphaBrowseFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..7963010591c4df607eeb1bc6e16291890bd21fe3 --- /dev/null +++ b/module/VuFind/src/VuFind/ChannelProvider/AlphaBrowseFactory.php @@ -0,0 +1,71 @@ +<?php +/** + * Factory for AlphaBrowse channel provider. + * + * PHP version 7 + * + * Copyright (C) Villanova University 2019. + * + * 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 Channels + * @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\ChannelProvider; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + +/** + * Factory for AlphaBrowse channel provider. + * + * @category VuFind + * @package Channels + * @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 ($options !== null) { + throw new \Exception('Unexpected options sent to factory!'); + } + return new $requestedName( + $container->get(\VuFindSearch\Service::class), + $container->get(\VuFind\Search\BackendManager::class)->get('Solr'), + $container->get('ControllerPluginManager')->get('url'), + $container->get(\VuFind\Record\Router::class) + ); + } +} diff --git a/module/VuFind/src/VuFind/ChannelProvider/FacetsFactory.php b/module/VuFind/src/VuFind/ChannelProvider/FacetsFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..d3a9acb58b8b53621bdcc28cb1b73cccf25a7c73 --- /dev/null +++ b/module/VuFind/src/VuFind/ChannelProvider/FacetsFactory.php @@ -0,0 +1,69 @@ +<?php +/** + * Factory for Facets channel provider. + * + * PHP version 7 + * + * Copyright (C) Villanova University 2019. + * + * 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 Channels + * @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\ChannelProvider; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + +/** + * Factory for Facets channel provider. + * + * @category VuFind + * @package Channels + * @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 FacetsFactory 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 ($options !== null) { + throw new \Exception('Unexpected options sent to factory!'); + } + return new $requestedName( + $container->get(\VuFind\Search\Results\PluginManager::class), + $container->get('ControllerPluginManager')->get('url') + ); + } +} diff --git a/module/VuFind/src/VuFind/ChannelProvider/Factory.php b/module/VuFind/src/VuFind/ChannelProvider/Factory.php deleted file mode 100644 index b4014736630a7df8472ece79032bf70944ceb2ac..0000000000000000000000000000000000000000 --- a/module/VuFind/src/VuFind/ChannelProvider/Factory.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php -/** - * Factory for ChannelProvider plugins. - * - * PHP version 7 - * - * Copyright (C) Villanova University 2016. - * - * 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 Channels - * @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\ChannelProvider; - -use Zend\ServiceManager\ServiceManager; - -/** - * Factory for ChannelProvider plugins. - * - * @category VuFind - * @package Channels - * @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 AlphaBrowse channel provider. - * - * @param ServiceManager $sm Service manager. - * - * @return AlphaBrowse - */ - public static function getAlphaBrowse(ServiceManager $sm) - { - return new AlphaBrowse( - $sm->get('VuFindSearch\Service'), - $sm->get('VuFind\Search\BackendManager') - ->get('Solr'), - $sm->get('ControllerPluginManager')->get('url'), - $sm->get('VuFind\Record\Router') - ); - } - - /** - * Construct the Facets channel provider. - * - * @param ServiceManager $sm Service manager. - * - * @return Facets - */ - public static function getFacets(ServiceManager $sm) - { - return new Facets( - $sm->get('VuFind\Search\Results\PluginManager'), - $sm->get('ControllerPluginManager')->get('url') - ); - } - - /** - * Construct the ListItems channel provider. - * - * @param ServiceManager $sm Service manager. - * - * @return ListItems - */ - public static function getListItems(ServiceManager $sm) - { - return new ListItems( - $sm->get('VuFind\Db\Table\PluginManager')->get('UserList'), - $sm->get('ControllerPluginManager')->get('url'), - $sm->get('VuFind\Search\Results\PluginManager') - ); - } - - /** - * Construct the Random channel provider. - * - * @param ServiceManager $sm Service manager. - * - * @return Random - */ - public static function getRandom(ServiceManager $sm) - { - return new Random( - $sm->get('VuFindSearch\Service'), - $sm->get('VuFind\Search\Params\PluginManager') - ); - } - - /** - * Construct the SimilarItems channel provider. - * - * @param ServiceManager $sm Service manager. - * - * @return SimilarItems - */ - public static function getSimilarItems(ServiceManager $sm) - { - return new SimilarItems( - $sm->get('VuFindSearch\Service'), - $sm->get('ControllerPluginManager')->get('url'), - $sm->get('VuFind\Record\Router') - ); - } -} diff --git a/module/VuFind/src/VuFind/ChannelProvider/ListItemsFactory.php b/module/VuFind/src/VuFind/ChannelProvider/ListItemsFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..31484b6352a965babb62ed5343062079ffed0afc --- /dev/null +++ b/module/VuFind/src/VuFind/ChannelProvider/ListItemsFactory.php @@ -0,0 +1,70 @@ +<?php +/** + * Factory for ListItems channel provider. + * + * PHP version 7 + * + * Copyright (C) Villanova University 2019. + * + * 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 Channels + * @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\ChannelProvider; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + +/** + * Factory for ListItems channel provider. + * + * @category VuFind + * @package Channels + * @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 ListItemsFactory 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 ($options !== null) { + throw new \Exception('Unexpected options sent to factory!'); + } + return new $requestedName( + $container->get(\VuFind\Db\Table\PluginManager::class)->get('UserList'), + $container->get('ControllerPluginManager')->get('url'), + $container->get(\VuFind\Search\Results\PluginManager::class) + ); + } +} diff --git a/module/VuFind/src/VuFind/ChannelProvider/PluginManager.php b/module/VuFind/src/VuFind/ChannelProvider/PluginManager.php index 603b7c1254d6e0c9459302c4c9c55244867951b1..8909b6777f4f9ba8e87abcea22de6d093b3eb56c 100644 --- a/module/VuFind/src/VuFind/ChannelProvider/PluginManager.php +++ b/module/VuFind/src/VuFind/ChannelProvider/PluginManager.php @@ -44,14 +44,14 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager * @var array */ protected $aliases = [ - 'alphabrowse' => 'VuFind\ChannelProvider\AlphaBrowse', - 'facets' => 'VuFind\ChannelProvider\Facets', - 'listitems' => 'VuFind\ChannelProvider\ListItems', - 'newilsitems' => 'VuFind\ChannelProvider\NewILSItems', - 'random' => 'VuFind\ChannelProvider\Random', - 'recentlyreturned' => 'VuFind\ChannelProvider\RecentlyReturned', - 'similaritems' => 'VuFind\ChannelProvider\SimilarItems', - 'trendingilsitems' => 'VuFind\ChannelProvider\TrendingILSItems', + 'alphabrowse' => AlphaBrowse::class, + 'facets' => Facets::class, + 'listitems' => ListItems::class, + 'newilsitems' => NewILSItems::class, + 'random' => Random::class, + 'recentlyreturned' => RecentlyReturned::class, + 'similaritems' => SimilarItems::class, + 'trendingilsitems' => TrendingILSItems::class, ]; /** @@ -60,22 +60,14 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager * @var array */ protected $factories = [ - 'VuFind\ChannelProvider\AlphaBrowse' => - 'VuFind\ChannelProvider\Factory::getAlphaBrowse', - 'VuFind\ChannelProvider\Facets' => - 'VuFind\ChannelProvider\Factory::getFacets', - 'VuFind\ChannelProvider\ListItems' => - 'VuFind\ChannelProvider\Factory::getListItems', - 'VuFind\ChannelProvider\NewILSItems' => - 'VuFind\ChannelProvider\AbstractILSChannelProviderFactory', - 'VuFind\ChannelProvider\Random' => - 'VuFind\ChannelProvider\Factory::getRandom', - 'VuFind\ChannelProvider\RecentlyReturned' => - 'VuFind\ChannelProvider\AbstractILSChannelProviderFactory', - 'VuFind\ChannelProvider\SimilarItems' => - 'VuFind\ChannelProvider\Factory::getSimilarItems', - 'VuFind\ChannelProvider\TrendingILSItems' => - 'VuFind\ChannelProvider\AbstractILSChannelProviderFactory', + AlphaBrowse::class => AlphaBrowseFactory::class, + Facets::class => FacetsFactory::class, + ListItems::class => ListItemsFactory::class, + NewILSItems::class => AbstractILSChannelProviderFactory::class, + Random::class => RandomFactory::class, + RecentlyReturned::class => AbstractILSChannelProviderFactory::class, + SimilarItems::class => SimilarItemsFactory::class, + TrendingILSItems::class => AbstractILSChannelProviderFactory::class, ]; /** @@ -90,7 +82,7 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager public function __construct($configOrContainerInstance = null, array $v3config = [] ) { - $this->addInitializer('VuFind\ChannelProvider\RouterInitializer'); + $this->addInitializer(RouterInitializer::class); parent::__construct($configOrContainerInstance, $v3config); } @@ -102,6 +94,6 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager */ protected function getExpectedInterface() { - return 'VuFind\ChannelProvider\ChannelProviderInterface'; + return ChannelProviderInterface::class; } } diff --git a/module/VuFind/src/VuFind/ChannelProvider/RandomFactory.php b/module/VuFind/src/VuFind/ChannelProvider/RandomFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..00e6e73d226808a38e1663fc8ba6a6a61543ef35 --- /dev/null +++ b/module/VuFind/src/VuFind/ChannelProvider/RandomFactory.php @@ -0,0 +1,69 @@ +<?php +/** + * Factory for Random channel provider. + * + * PHP version 7 + * + * Copyright (C) Villanova University 2019. + * + * 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 Channels + * @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\ChannelProvider; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + +/** + * Factory for Random channel provider. + * + * @category VuFind + * @package Channels + * @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 RandomFactory 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 ($options !== null) { + throw new \Exception('Unexpected options sent to factory!'); + } + return new $requestedName( + $container->get(\VuFindSearch\Service::class), + $container->get(\VuFind\Search\Params\PluginManager::class) + ); + } +} diff --git a/module/VuFind/src/VuFind/ChannelProvider/SimilarItemsFactory.php b/module/VuFind/src/VuFind/ChannelProvider/SimilarItemsFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..af6017de1872233297d4bcdb13f261c63df9a4b0 --- /dev/null +++ b/module/VuFind/src/VuFind/ChannelProvider/SimilarItemsFactory.php @@ -0,0 +1,70 @@ +<?php +/** + * Factory for SimilarItems channel provider. + * + * PHP version 7 + * + * Copyright (C) Villanova University 2019. + * + * 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 Channels + * @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\ChannelProvider; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + +/** + * Factory for SimilarItems channel provider. + * + * @category VuFind + * @package Channels + * @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 SimilarItemsFactory 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 ($options !== null) { + throw new \Exception('Unexpected options sent to factory!'); + } + return new $requestedName( + $container->get(\VuFindSearch\Service::class), + $container->get('ControllerPluginManager')->get('url'), + $container->get(\VuFind\Record\Router::class) + ); + } +}