The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

Skip to content
Snippets Groups Projects
Commit 1f2d7703 authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Eliminate static channel provider factories.

parent 857e85d4
No related merge requests found
<?php
/**
* Factory for ChannelProvider plugins.
* Factory for AlphaBrowse channel provider.
*
* PHP version 7
*
* Copyright (C) Villanova University 2016.
* 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,
......@@ -27,98 +27,45 @@
*/
namespace VuFind\ChannelProvider;
use Zend\ServiceManager\ServiceManager;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\FactoryInterface;
/**
* Factory for ChannelProvider plugins.
* 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
*
* @codeCoverageIgnore
*/
class Factory
class AlphaBrowseFactory implements FactoryInterface
{
/**
* 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.
* Create an object
*
* @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 ContainerInterface $container Service manager
* @param string $requestedName Service being created
* @param null|array $options Extra options (optional)
*
* @param ServiceManager $sm Service manager.
* @return object
*
* @return SimilarItems
* @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 static function getSimilarItems(ServiceManager $sm)
{
return new SimilarItems(
$sm->get('VuFindSearch\Service'),
$sm->get('ControllerPluginManager')->get('url'),
$sm->get('VuFind\Record\Router')
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)
);
}
}
<?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')
);
}
}
<?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)
);
}
}
......@@ -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;
}
}
<?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)
);
}
}
<?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)
);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment