diff --git a/module/VuFind/src/VuFind/RecordDriver/AbstractBaseFactory.php b/module/VuFind/src/VuFind/RecordDriver/AbstractBaseFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..da058162ec3194c91b2b9a19785b09da16ed6f2d --- /dev/null +++ b/module/VuFind/src/VuFind/RecordDriver/AbstractBaseFactory.php @@ -0,0 +1,64 @@ +<?php +/** + * Default factory for record drivers. + * + * 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 RecordDrivers + * @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\RecordDriver; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + +/** + * Default factory for record drivers. + * + * @category VuFind + * @package RecordDrivers + * @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 AbstractBaseFactory 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 + ) { + $mainConfig = $container->get('VuFind\Config\PluginManager')->get('config'); + return new $requestedName($mainConfig, ...($options ?: [])); + } +} diff --git a/module/VuFind/src/VuFind/RecordDriver/Factory.php b/module/VuFind/src/VuFind/RecordDriver/Factory.php deleted file mode 100644 index 754de07032095682d2349b70ef8e85502a9205a1..0000000000000000000000000000000000000000 --- a/module/VuFind/src/VuFind/RecordDriver/Factory.php +++ /dev/null @@ -1,268 +0,0 @@ -<?php -/** - * Record Driver Factory Class - * - * 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 RecordDrivers - * @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:plugins:hierarchy_components Wiki - */ -namespace VuFind\RecordDriver; - -use Zend\ServiceManager\ServiceManager; - -/** - * Record Driver Factory Class - * - * @category VuFind - * @package RecordDrivers - * @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:plugins:hierarchy_components Wiki - * - * @codeCoverageIgnore - */ -class Factory -{ - /** - * Factory for EDS record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return EDS - */ - public static function getEDS(ServiceManager $sm) - { - $eds = $sm->get('VuFind\Config\PluginManager')->get('EDS'); - return new EDS( - $sm->get('VuFind\Config\PluginManager')->get('config'), $eds, $eds - ); - } - - /** - * Factory for EIT record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return EIT - */ - public static function getEIT(ServiceManager $sm) - { - $eit = $sm->get('VuFind\Config\PluginManager')->get('EIT'); - return new EIT( - $sm->get('VuFind\Config\PluginManager')->get('config'), $eit, $eit - ); - } - - /** - * Factory for Missing record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return Missing - */ - public static function getMissing(ServiceManager $sm) - { - return new Missing( - $sm->get('VuFind\Config\PluginManager')->get('config') - ); - } - - /** - * Factory for Pazpar2 record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return Pazpar2 - */ - public static function getPazpar2(ServiceManager $sm) - { - $pp2 = $sm->get('VuFind\Config\PluginManager')->get('Pazpar2'); - return new Pazpar2( - $sm->get('VuFind\Config\PluginManager')->get('config'), $pp2, $pp2 - ); - } - - /** - * Factory for Primo record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return Primo - */ - public static function getPrimo(ServiceManager $sm) - { - $primo = $sm->get('VuFind\Config\PluginManager')->get('Primo'); - $driver = new Primo( - $sm->get('VuFind\Config\PluginManager')->get('config'), - $primo, $primo - ); - return $driver; - } - - /** - * Factory for SolrAuth record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return SolrAuth - */ - public static function getSolrAuth(ServiceManager $sm) - { - return new SolrAuth( - $sm->get('VuFind\Config\PluginManager')->get('config'), - null, - $sm->get('VuFind\Config\PluginManager')->get('searches') - ); - } - - /** - * Factory for SolrDefault record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return SolrDefault - */ - public static function getSolrDefault(ServiceManager $sm) - { - $driver = new SolrDefault( - $sm->get('VuFind\Config\PluginManager')->get('config'), - null, - $sm->get('VuFind\Config\PluginManager')->get('searches') - ); - $driver->attachSearchService($sm->get('VuFindSearch\Service')); - return $driver; - } - - /** - * Factory for SolrMarc record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return SolrMarc - */ - public static function getSolrMarc(ServiceManager $sm) - { - $driver = new SolrMarc( - $sm->get('VuFind\Config\PluginManager')->get('config'), - null, - $sm->get('VuFind\Config\PluginManager')->get('searches') - ); - if ($sm->has('VuFind\ILS\Connection')) { - $driver->attachILS( - $sm->get('VuFind\ILS\Connection'), - $sm->get('VuFind\ILS\Logic\Holds'), - $sm->get('VuFind\ILS\Logic\TitleHolds') - ); - } - $driver->attachSearchService($sm->get('VuFindSearch\Service')); - return $driver; - } - - /** - * Factory for SolrMarcRemote record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return SolrMarc - */ - public static function getSolrMarcRemote(ServiceManager $sm) - { - $driver = new SolrMarcRemote( - $sm->get('VuFind\Config\PluginManager')->get('config'), - null, - $sm->get('VuFind\Config\PluginManager')->get('searches') - ); - if ($sm->has('VuFind\ILS\Connection')) { - $driver->attachILS( - $sm->get('VuFind\ILS\Connection'), - $sm->get('VuFind\ILS\Logic\Holds'), - $sm->get('VuFind\ILS\Logic\TitleHolds') - ); - } - $driver->attachSearchService($sm->get('VuFindSearch\Service')); - return $driver; - } - - /** - * Factory for SolrReserves record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return SolrReserves - */ - public static function getSolrReserves(ServiceManager $sm) - { - return new SolrReserves( - $sm->get('VuFind\Config\PluginManager')->get('config'), - null, - $sm->get('VuFind\Config\PluginManager')->get('searches') - ); - } - - /** - * Factory for SolrWeb record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return SolrWeb - */ - public static function getSolrWeb(ServiceManager $sm) - { - $web = $sm->get('VuFind\Config\PluginManager')->get('website'); - return new SolrWeb( - $sm->get('VuFind\Config\PluginManager')->get('config'), $web, $web - ); - } - - /** - * Factory for Summon record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return Summon - */ - public static function getSummon(ServiceManager $sm) - { - $summon = $sm->get('VuFind\Config\PluginManager')->get('Summon'); - $driver = new Summon( - $sm->get('VuFind\Config\PluginManager')->get('config'), - $summon, $summon - ); - $driver->setDateConverter($sm->get('VuFind\Date\Converter')); - return $driver; - } - - /** - * Factory for WorldCat record driver. - * - * @param ServiceManager $sm Service manager. - * - * @return WorldCat - */ - public static function getWorldCat(ServiceManager $sm) - { - $wc = $sm->get('VuFind\Config\PluginManager')->get('WorldCat'); - return new WorldCat( - $sm->get('VuFind\Config\PluginManager')->get('config'), $wc, $wc - ); - } -} diff --git a/module/VuFind/src/VuFind/RecordDriver/NameBasedConfigFactory.php b/module/VuFind/src/VuFind/RecordDriver/NameBasedConfigFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..845b40741d5c8d51ccf4db8591d09c7c265b5b06 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordDriver/NameBasedConfigFactory.php @@ -0,0 +1,69 @@ +<?php +/** + * Factory for record drivers that uses the class name to look up config files. + * + * 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 RecordDrivers + * @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\RecordDriver; + +use Interop\Container\ContainerInterface; + +/** + * Factory for record drivers that uses the class name to look up config files. + * + * @category VuFind + * @package RecordDrivers + * @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 NameBasedConfigFactory extends AbstractBaseFactory +{ + /** + * 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.'); + } + $parts = explode('\\', $requestedName); + $configName = array_pop($parts); + $config = $container->get('VuFind\Config\PluginManager')->get($configName); + $finalOptions = [$config, $config]; + return parent::__invoke($container, $requestedName, $finalOptions); + } +} diff --git a/module/VuFind/src/VuFind/RecordDriver/PluginManager.php b/module/VuFind/src/VuFind/RecordDriver/PluginManager.php index 2a4d5d2354b3944cb3171e0a1b7789d911f891a8..7b734e1fea76ceaed448f7a19795e7ce13c2099d 100644 --- a/module/VuFind/src/VuFind/RecordDriver/PluginManager.php +++ b/module/VuFind/src/VuFind/RecordDriver/PluginManager.php @@ -69,24 +69,27 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager protected $factories = [ 'VuFind\RecordDriver\BrowZine' => 'Zend\ServiceManager\Factory\InvokableFactory', - 'VuFind\RecordDriver\EDS' => 'VuFind\RecordDriver\Factory::getEDS', - 'VuFind\RecordDriver\EIT' => 'VuFind\RecordDriver\Factory::getEIT', + 'VuFind\RecordDriver\EDS' => 'VuFind\RecordDriver\NameBasedConfigFactory', + 'VuFind\RecordDriver\EIT' => 'VuFind\RecordDriver\NameBasedConfigFactory', 'VuFind\RecordDriver\LibGuides' => 'Zend\ServiceManager\Factory\InvokableFactory', - 'VuFind\RecordDriver\Missing' => 'VuFind\RecordDriver\Factory::getMissing', - 'VuFind\RecordDriver\Pazpar2' => 'VuFind\RecordDriver\Factory::getPazpar2', - 'VuFind\RecordDriver\Primo' => 'VuFind\RecordDriver\Factory::getPrimo', - 'VuFind\RecordDriver\SolrAuth' => 'VuFind\RecordDriver\Factory::getSolrAuth', + 'VuFind\RecordDriver\Missing' => 'VuFind\RecordDriver\AbstractBaseFactory', + 'VuFind\RecordDriver\Pazpar2' => + 'VuFind\RecordDriver\NameBasedConfigFactory', + 'VuFind\RecordDriver\Primo' => 'VuFind\RecordDriver\NameBasedConfigFactory', + 'VuFind\RecordDriver\SolrAuth' => + 'VuFind\RecordDriver\SolrDefaultWithoutSearchServiceFactory', 'VuFind\RecordDriver\SolrDefault' => - 'VuFind\RecordDriver\Factory::getSolrDefault', - 'VuFind\RecordDriver\SolrMarc' => 'VuFind\RecordDriver\Factory::getSolrMarc', + 'VuFind\RecordDriver\SolrDefaultFactory', + 'VuFind\RecordDriver\SolrMarc' => 'VuFind\RecordDriver\SolrMarcFactory', 'VuFind\RecordDriver\SolrMarcRemote' => - 'VuFind\RecordDriver\Factory::getSolrMarcRemote', + 'VuFind\RecordDriver\SolrMarcFactory', 'VuFind\RecordDriver\SolrReserves' => - 'VuFind\RecordDriver\Factory::getSolrReserves', - 'VuFind\RecordDriver\SolrWeb' => 'VuFind\RecordDriver\Factory::getSolrWeb', - 'VuFind\RecordDriver\Summon' => 'VuFind\RecordDriver\Factory::getSummon', - 'VuFind\RecordDriver\WorldCat' => 'VuFind\RecordDriver\Factory::getWorldCat', + 'VuFind\RecordDriver\SolrDefaultWithoutSearchServiceFactory', + 'VuFind\RecordDriver\SolrWeb' => 'VuFind\RecordDriver\SolrWebFactory', + 'VuFind\RecordDriver\Summon' => 'VuFind\RecordDriver\SummonFactory', + 'VuFind\RecordDriver\WorldCat' => + 'VuFind\RecordDriver\NameBasedConfigFactory', ]; /** diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrDefaultFactory.php b/module/VuFind/src/VuFind/RecordDriver/SolrDefaultFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..80dca9410831c0abdedfc7c830672f5456743932 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordDriver/SolrDefaultFactory.php @@ -0,0 +1,64 @@ +<?php +/** + * Factory for SolrDefault record drivers. + * + * 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 RecordDrivers + * @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\RecordDriver; + +use Interop\Container\ContainerInterface; + +/** + * Factory for SolrDefault record drivers. + * + * @category VuFind + * @package RecordDrivers + * @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 SolrDefaultFactory extends SolrDefaultWithoutSearchServiceFactory +{ + /** + * 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 + ) { + $driver = parent::__invoke($container, $requestedName, $options); + $driver->attachSearchService($container->get('VuFindSearch\Service')); + return $driver; + } +} diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrDefaultWithoutSearchServiceFactory.php b/module/VuFind/src/VuFind/RecordDriver/SolrDefaultWithoutSearchServiceFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..c24019b7dab7ba03784b5b4b60dd0492386cdbe1 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordDriver/SolrDefaultWithoutSearchServiceFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * Factory for SolrDefault-based record drivers that do not need a search service. + * + * 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 RecordDrivers + * @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\RecordDriver; + +use Interop\Container\ContainerInterface; + +/** + * Factory for SolrDefault-based record drivers that do not need a search service. + * + * @category VuFind + * @package RecordDrivers + * @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 SolrDefaultWithoutSearchServiceFactory extends AbstractBaseFactory +{ + /** + * 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('searches'); + $finalOptions = [null, $config]; + return parent::__invoke($container, $requestedName, $finalOptions); + } +} diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrMarcFactory.php b/module/VuFind/src/VuFind/RecordDriver/SolrMarcFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..4fd9463a239bbbb431a430be0b478284b17f3ec7 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordDriver/SolrMarcFactory.php @@ -0,0 +1,70 @@ +<?php +/** + * Factory for SolrMarc record drivers. + * + * 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 RecordDrivers + * @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\RecordDriver; + +use Interop\Container\ContainerInterface; + +/** + * Factory for SolrMarc record drivers. + * + * @category VuFind + * @package RecordDrivers + * @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 SolrMarcFactory extends SolrDefaultFactory +{ + /** + * 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 + ) { + $driver = parent::__invoke($container, $requestedName, $options); + if ($container->has('VuFind\ILS\Connection')) { + $driver->attachILS( + $container->get('VuFind\ILS\Connection'), + $container->get('VuFind\ILS\Logic\Holds'), + $container->get('VuFind\ILS\Logic\TitleHolds') + ); + } + return $driver; + } +} diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrWebFactory.php b/module/VuFind/src/VuFind/RecordDriver/SolrWebFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..91cef38e71b86d113dba3849fce5eceeda3a7d35 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordDriver/SolrWebFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * Factory for SolrWeb record drivers. + * + * 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 RecordDrivers + * @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\RecordDriver; + +use Interop\Container\ContainerInterface; + +/** + * Factory for SolrWeb record drivers. + * + * @category VuFind + * @package RecordDrivers + * @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 SolrWebFactory extends AbstractBaseFactory +{ + /** + * 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('website'); + $finalOptions = [$config, $config]; + return parent::__invoke($container, $requestedName, $finalOptions); + } +} diff --git a/module/VuFind/src/VuFind/RecordDriver/SummonFactory.php b/module/VuFind/src/VuFind/RecordDriver/SummonFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..f39a757bca64a2ae17e9e24234f4379ae87e4884 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordDriver/SummonFactory.php @@ -0,0 +1,64 @@ +<?php +/** + * Factory for Summon record drivers. + * + * 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 RecordDrivers + * @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\RecordDriver; + +use Interop\Container\ContainerInterface; + +/** + * Factory for Summon record drivers. + * + * @category VuFind + * @package RecordDrivers + * @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 SummonFactory extends NameBasedConfigFactory +{ + /** + * 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 + ) { + $driver = parent::__invoke($container, $requestedName, $options); + $driver->setDateConverter($container->get('VuFind\Date\Converter')); + return $driver; + } +}