diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index a91c743560ffeb30994dd2b5d24c54fb5c416e79..246e123e84cd513aec72a21c82b8032729aef765 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -407,52 +407,13 @@ $config = [ 'auth' => [ /* see VuFind\Auth\PluginManager for defaults */ ], 'autocomplete' => [ /* see VuFind\Autocomplete\PluginManager for defaults */ ], 'channelprovider' => [ /* see VuFind\ChannelProvider\PluginManager for defaults */ ], - 'content' => [ - 'factories' => [ - 'authornotes' => 'VuFind\Content\Factory::getAuthorNotes', - 'excerpts' => 'VuFind\Content\Factory::getExcerpts', - 'reviews' => 'VuFind\Content\Factory::getReviews', - 'summaries' => 'VuFind\Content\Factory::getSummaries', - 'toc' => 'VuFind\Content\Factory::getTOC', - ], - ], - 'content_authornotes' => [ - 'factories' => [ - 'syndetics' => 'VuFind\Content\AuthorNotes\Factory::getSyndetics', - 'syndeticsplus' => 'VuFind\Content\AuthorNotes\Factory::getSyndeticsPlus', - ], - ], - 'content_excerpts' => [ - 'factories' => [ - 'syndetics' => 'VuFind\Content\Excerpts\Factory::getSyndetics', - 'syndeticsplus' => 'VuFind\Content\Excerpts\Factory::getSyndeticsPlus', - ], - ], - 'content_summaries' => [ - 'factories' => [ - 'syndetics' => 'VuFind\Content\Summaries\Factory::getSyndetics', - 'syndeticsplus' => 'VuFind\Content\Summaries\Factory::getSyndeticsPlus', - ], - ], - 'content_toc' => [ - 'factories' => [ - 'syndetics' => 'VuFind\Content\TOC\Factory::getSyndetics', - 'syndeticsplus' => 'VuFind\Content\TOC\Factory::getSyndeticsPlus', - ], - ], + 'content' => [ /* see VuFind\Content\PluginManager for defaults */ ], + 'content_authornotes' => [ /* see VuFind\Content\AuthorNotes\PluginManager for defaults */ ], 'content_covers' => [ /* see VuFind\Content\Covers\PluginManager for defaults */ ], - 'content_reviews' => [ - 'factories' => [ - 'amazon' => 'VuFind\Content\Reviews\Factory::getAmazon', - 'amazoneditorial' => 'VuFind\Content\Reviews\Factory::getAmazonEditorial', - 'booksite' => 'VuFind\Content\Reviews\Factory::getBooksite', - 'syndetics' => 'VuFind\Content\Reviews\Factory::getSyndetics', - 'syndeticsplus' => 'VuFind\Content\Reviews\Factory::getSyndeticsPlus', - ], - 'invokables' => [ - 'guardian' => 'VuFind\Content\Reviews\Guardian', - ], - ], + 'content_excerpts' => [ /* see VuFind\Content\Excerpts\PluginManager for defaults */ ], + 'content_reviews' => [ /* see VuFind\Content\Reviews\PluginManager for defaults */ ], + 'content_summaries' => [ /* see VuFind\Content\Summaries\PluginManager for defaults */ ], + 'content_toc' => [ /* see VuFind\Content\TOC\PluginManager for defaults */ ], 'db_row' => [ /* see VuFind\Db\Row\PluginManager for defaults */ ], 'db_table' => [ /* see VuFind\Db\Table\PluginManager for defaults */ ], 'hierarchy_driver' => [ diff --git a/module/VuFind/src/VuFind/Content/AbstractAmazonFactory.php b/module/VuFind/src/VuFind/Content/AbstractAmazonFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..0dc9b91bef9bef01250768fecd0d60f3af69e4dd --- /dev/null +++ b/module/VuFind/src/VuFind/Content/AbstractAmazonFactory.php @@ -0,0 +1,73 @@ +<?php +/** + * Generic Amazon content plugin factory. + * + * PHP version 5 + * + * 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 Content + * @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\Content; + +use Interop\Container\ContainerInterface; + +/** + * Generic Amazon content plugin factory. + * + * @category VuFind + * @package Content + * @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 AbstractAmazonFactory implements \Zend\ServiceManager\Factory\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!'); + } + $config = $container->get('VuFind\Config')->get('config'); + $associate = isset($config->Content->amazonassociate) + ? $config->Content->amazonassociate : null; + $secret = isset($config->Content->amazonsecret) + ? $config->Content->amazonsecret : null; + $label = $container->get('VuFind\Translator')->translate( + 'Supplied by Amazon' + ); + return new $requestedName($associate, $secret, $label); + } +} diff --git a/module/VuFind/src/VuFind/Content/AuthorNotes/Factory.php b/module/VuFind/src/VuFind/Content/AbstractSyndeticsFactory.php similarity index 51% rename from module/VuFind/src/VuFind/Content/AuthorNotes/Factory.php rename to module/VuFind/src/VuFind/Content/AbstractSyndeticsFactory.php index 8c76af748eda3b62e183d9d25cf79afe0cb2bcc1..d6f0d30ffaf06b4ce27ad054b0ba77f6b4c2ae99 100644 --- a/module/VuFind/src/VuFind/Content/AuthorNotes/Factory.php +++ b/module/VuFind/src/VuFind/Content/AbstractSyndeticsFactory.php @@ -1,10 +1,10 @@ <?php /** - * Factory for instantiating content loaders + * Generic Syndetics content plugin factory. * * PHP version 5 * - * Copyright (C) Villanova University 2009. + * 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, @@ -25,62 +25,52 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development Wiki */ -namespace VuFind\Content\AuthorNotes; +namespace VuFind\Content; -use Zend\ServiceManager\ServiceManager; +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; /** - * Factory for instantiating content loaders + * Generic Syndetics content plugin factory. * * @category VuFind * @package Content * @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 AbstractSyndeticsFactory implements FactoryInterface { /** - * Create either a Syndetics or SyndeticsPlus loader + * Create an object + * + * @param ContainerInterface $container Service manager + * @param string $requestedName Service being created + * @param null|array $options Extra options (optional) * - * @param ServiceManager $sm Service manager - * @param bool $plus Instantiate in Syndetics Plus mode? + * @return object * - * @return mixed + * @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 getAbstractSyndetics(ServiceManager $sm, $plus) - { - $config = $sm->get('VuFind\Config')->get('config'); - return new Syndetics( + public function __invoke(ContainerInterface $container, $requestedName, + array $options = null + ) { + $config = $container->get('VuFind\Config')->get('config'); + + // Special case: if the class name ends in Plus, we need to strip off + // the "Plus" and instead configure the base Syndetics class into "plus" + // mode. + $plus = substr($requestedName, -4) === 'Plus'; + $className = $plus + ? substr($requestedName, 0, strlen($requestedName) - 4) : $requestedName; + + return new $className( isset($config->Syndetics->use_ssl) && $config->Syndetics->use_ssl, $plus, isset($config->Syndetics->timeout) ? $config->Syndetics->timeout : 10 ); } - - /** - * Create Syndetics loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getSyndetics(ServiceManager $sm) - { - return static::getAbstractSyndetics($sm, false); - } - - /** - * Create SyndeticsPlus loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getSyndeticsPlus(ServiceManager $sm) - { - return static::getAbstractSyndetics($sm, true); - } } diff --git a/module/VuFind/src/VuFind/Content/AuthorNotes/PluginManager.php b/module/VuFind/src/VuFind/Content/AuthorNotes/PluginManager.php index 67c52c12434869fc6d5f004ee040e151b086f767..3e54336db1e8705e615a870c164489c8a681d88f 100644 --- a/module/VuFind/src/VuFind/Content/AuthorNotes/PluginManager.php +++ b/module/VuFind/src/VuFind/Content/AuthorNotes/PluginManager.php @@ -38,6 +38,28 @@ namespace VuFind\Content\AuthorNotes; */ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager { + /** + * Default plugin aliases. + * + * @var array + */ + protected $aliases = [ + 'syndetics' => 'VuFind\Content\AuthorNotes\Syndetics', + 'syndeticsplus' => 'VuFind\Content\AuthorNotes\SyndeticsPlus', + ]; + + /** + * Default plugin factories. + * + * @var array + */ + protected $factories = [ + 'VuFind\Content\AuthorNotes\Syndetics' => + 'VuFind\Content\AbstractSyndeticsFactory', + 'VuFind\Content\AuthorNotes\SyndeticsPlus' => + 'VuFind\Content\AbstractSyndeticsFactory', + ]; + /** * Return the name of the base class or interface that plug-ins must conform * to. diff --git a/module/VuFind/src/VuFind/Content/Excerpts/Factory.php b/module/VuFind/src/VuFind/Content/Excerpts/Factory.php deleted file mode 100644 index b931ca8360e22379ecb264f1fa38021fac6cdac6..0000000000000000000000000000000000000000 --- a/module/VuFind/src/VuFind/Content/Excerpts/Factory.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php -/** - * Factory for instantiating content loaders - * - * PHP version 5 - * - * Copyright (C) Villanova University 2009. - * - * 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 Content - * @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\Content\Excerpts; - -use Zend\ServiceManager\ServiceManager; - -/** - * Factory for instantiating content loaders - * - * @category VuFind - * @package Content - * @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 -{ - /** - * Create either a Syndetics or SyndeticsPlus loader - * - * @param ServiceManager $sm Service manager - * @param bool $plus Instantiate in Syndetics Plus mode? - * - * @return mixed - */ - public static function getAbstractSyndetics(ServiceManager $sm, $plus) - { - $config = $sm->get('VuFind\Config')->get('config'); - return new Syndetics( - isset($config->Syndetics->use_ssl) && $config->Syndetics->use_ssl, - $plus, - isset($config->Syndetics->timeout) ? $config->Syndetics->timeout : 10 - ); - } - - /** - * Create Syndetics loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getSyndetics(ServiceManager $sm) - { - return static::getAbstractSyndetics($sm, false); - } - - /** - * Create SyndeticsPlus loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getSyndeticsPlus(ServiceManager $sm) - { - return static::getAbstractSyndetics($sm, true); - } -} diff --git a/module/VuFind/src/VuFind/Content/Excerpts/PluginManager.php b/module/VuFind/src/VuFind/Content/Excerpts/PluginManager.php index 10e0be3e3a1ffcd9823bc1f5c44b0e99fd2f5557..42ffb32d0bd51f24fdead78b523d480de26fc4c5 100644 --- a/module/VuFind/src/VuFind/Content/Excerpts/PluginManager.php +++ b/module/VuFind/src/VuFind/Content/Excerpts/PluginManager.php @@ -38,6 +38,28 @@ namespace VuFind\Content\Excerpts; */ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager { + /** + * Default plugin aliases. + * + * @var array + */ + protected $aliases = [ + 'syndetics' => 'VuFind\Content\Excerpts\Syndetics', + 'syndeticsplus' => 'VuFind\Content\Excerpts\SyndeticsPlus', + ]; + + /** + * Default plugin factories. + * + * @var array + */ + protected $factories = [ + 'VuFind\Content\Excerpts\Syndetics' => + 'VuFind\Content\AbstractSyndeticsFactory', + 'VuFind\Content\Excerpts\SyndeticsPlus' => + 'VuFind\Content\AbstractSyndeticsFactory', + ]; + /** * Return the name of the base class or interface that plug-ins must conform * to. diff --git a/module/VuFind/src/VuFind/Content/PluginManager.php b/module/VuFind/src/VuFind/Content/PluginManager.php index 3277fd31118a3738f7c479d006fb71afc616e9bd..b14282a378c296e2a501a7e3546579c276778fb8 100644 --- a/module/VuFind/src/VuFind/Content/PluginManager.php +++ b/module/VuFind/src/VuFind/Content/PluginManager.php @@ -38,6 +38,19 @@ namespace VuFind\Content; */ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager { + /** + * Default plugin factories. + * + * @var array + */ + protected $factories = [ + 'authornotes' => 'VuFind\Content\Factory::getAuthorNotes', + 'excerpts' => 'VuFind\Content\Factory::getExcerpts', + 'reviews' => 'VuFind\Content\Factory::getReviews', + 'summaries' => 'VuFind\Content\Factory::getSummaries', + 'toc' => 'VuFind\Content\Factory::getTOC', + ]; + /** * Return the name of the base class or interface that plug-ins must conform * to. diff --git a/module/VuFind/src/VuFind/Content/Reviews/BooksiteFactory.php b/module/VuFind/src/VuFind/Content/Reviews/BooksiteFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..d279bfbc06e3a10c7806a6d5663458a1daecbd2b --- /dev/null +++ b/module/VuFind/src/VuFind/Content/Reviews/BooksiteFactory.php @@ -0,0 +1,71 @@ +<?php +/** + * Booksite review plugin factory. + * + * PHP version 5 + * + * 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 Content + * @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\Content\Reviews; + +use Interop\Container\ContainerInterface; + +/** + * Booksite review plugin factory. + * + * @category VuFind + * @package Content + * @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 BooksiteFactory implements \Zend\ServiceManager\Factory\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!'); + } + $config = $container->get('VuFind\Config')->get('config'); + $url = isset($config->Booksite->url) + ? $config->Booksite->url : 'https://api.booksite.com'; + if (!isset($config->Booksite->key)) { + throw new \Exception("Booksite 'key' not set in VuFind config"); + } + return new $requestedName($url, $config->Booksite->key); + } +} diff --git a/module/VuFind/src/VuFind/Content/Reviews/Factory.php b/module/VuFind/src/VuFind/Content/Reviews/Factory.php deleted file mode 100644 index 5de2f2b5059c1cff215bf5a1a9e5e418ef9c203a..0000000000000000000000000000000000000000 --- a/module/VuFind/src/VuFind/Content/Reviews/Factory.php +++ /dev/null @@ -1,144 +0,0 @@ -<?php -/** - * Factory for instantiating content loaders - * - * PHP version 5 - * - * Copyright (C) Villanova University 2009. - * - * 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 Content - * @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\Content\Reviews; - -use Zend\ServiceManager\ServiceManager; - -/** - * Factory for instantiating content loaders - * - * @category VuFind - * @package Content - * @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 -{ - /** - * Create either a Syndetics or SyndeticsPlus loader - * - * @param ServiceManager $sm Service manager - * @param bool $plus Instantiate in Syndetics Plus mode? - * - * @return mixed - */ - public static function getAbstractSyndetics(ServiceManager $sm, $plus) - { - $config = $sm->get('VuFind\Config')->get('config'); - return new Syndetics( - isset($config->Syndetics->use_ssl) && $config->Syndetics->use_ssl, - $plus, - isset($config->Syndetics->timeout) ? $config->Syndetics->timeout : 10 - ); - } - - /** - * Create Amazon loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getAmazon(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config')->get('config'); - $associate = isset($config->Content->amazonassociate) - ? $config->Content->amazonassociate : null; - $secret = isset($config->Content->amazonsecret) - ? $config->Content->amazonsecret : null; - $label = $sm->get('VuFind\Translator')->translate( - 'Supplied by Amazon' - ); - return new Amazon($associate, $secret, $label); - } - - /** - * Create AmazonEditorial loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getAmazonEditorial(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config')->get('config'); - $associate = isset($config->Content->amazonassociate) - ? $config->Content->amazonassociate : null; - $secret = isset($config->Content->amazonsecret) - ? $config->Content->amazonsecret : null; - $label = $sm->get('VuFind\Translator')->translate( - 'Supplied by Amazon' - ); - return new AmazonEditorial($associate, $secret, $label); - } - - /** - * Create Booksite loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getBooksite(ServiceManager $sm) - { - $config = $sm->get('VuFind\Config')->get('config'); - $url = isset($config->Booksite->url) - ? $config->Booksite->url : 'https://api.booksite.com'; - if (!isset($config->Booksite->key)) { - throw new \Exception("Booksite 'key' not set in VuFind config"); - } - return new Booksite($url, $config->Booksite->key); - } - - /** - * Create Syndetics loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getSyndetics(ServiceManager $sm) - { - return static::getAbstractSyndetics($sm, false); - } - - /** - * Create SyndeticsPlus loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getSyndeticsPlus(ServiceManager $sm) - { - return static::getAbstractSyndetics($sm, true); - } -} diff --git a/module/VuFind/src/VuFind/Content/Reviews/PluginManager.php b/module/VuFind/src/VuFind/Content/Reviews/PluginManager.php index c21ebdab35573ab2cee3c3d1b9376ce2600d2aba..0177ac002db7801b8895fe956b2659ff8f3306d1 100644 --- a/module/VuFind/src/VuFind/Content/Reviews/PluginManager.php +++ b/module/VuFind/src/VuFind/Content/Reviews/PluginManager.php @@ -38,6 +38,39 @@ namespace VuFind\Content\Reviews; */ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager { + /** + * Default plugin aliases. + * + * @var array + */ + protected $aliases = [ + 'amazon' => 'VuFind\Content\Reviews\Amazon', + 'amazoneditorial' => 'VuFind\Content\Reviews\AmazonEditorial', + 'booksite' => 'VuFind\Content\Reviews\Booksite', + 'guardian' => 'VuFind\Content\Reviews\Guardian', + 'syndetics' => 'VuFind\Content\Reviews\Syndetics', + 'syndeticsplus' => 'VuFind\Content\Reviews\SyndeticsPlus', + ]; + + /** + * Default plugin factories. + * + * @var array + */ + protected $factories = [ + 'VuFind\Content\Reviews\Amazon' => 'VuFind\Content\AbstractAmazonFactory', + 'VuFind\Content\Reviews\AmazonEditorial' => + 'VuFind\Content\AbstractAmazonFactory', + 'VuFind\Content\Reviews\Booksite' => + 'VuFind\Content\Reviews\BooksiteFactory', + 'VuFind\Content\Reviews\Guardian' => + 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\Content\Reviews\Syndetics' => + 'VuFind\Content\AbstractSyndeticsFactory', + 'VuFind\Content\Reviews\SyndeticsPlus' => + 'VuFind\Content\AbstractSyndeticsFactory', + ]; + /** * Return the name of the base class or interface that plug-ins must conform * to. diff --git a/module/VuFind/src/VuFind/Content/Summaries/Factory.php b/module/VuFind/src/VuFind/Content/Summaries/Factory.php deleted file mode 100644 index a4f45a2f1882945133c66bb86178100a4ef7e6f3..0000000000000000000000000000000000000000 --- a/module/VuFind/src/VuFind/Content/Summaries/Factory.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php -/** - * Factory for instantiating content loaders - * - * PHP version 5 - * - * Copyright (C) The University of Chicago 2017. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @category VuFind2 - * @package Content - * @author John Jung <jej@uchicago.edu> - * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License - * @link http://vufind.org/wiki/vufind2:developer_manual Wiki - */ -namespace VuFind\Content\Summaries; - -use Zend\ServiceManager\ServiceManager; - -/** - * Factory for instantiating content loaders - * - * @category VuFind2 - * @package Content - * @author John Jung <jej@uchicago.edu> - * @license http://opensource.org/licenses/gpl-2.0.php GNU General - * Public License - * @link http://vufind.org/wiki/vufind2:developer_manual Wiki - * @codeCoverageIgnore - */ -class Factory -{ - /** - * Create either a Syndetics or SyndeticsPlus loader - * - * @param ServiceManager $sm Service manager - * @param bool $plus Instantiate in Syndetics Plus mode? - * - * @return mixed - */ - public static function getAbstractSyndetics(ServiceManager $sm, $plus) - { - $config = $sm->get('VuFind\Config')->get('config'); - return new Syndetics( - isset($config->Syndetics->use_ssl) && $config->Syndetics->use_ssl, - $plus, - isset($config->Syndetics->timeout) ? $config->Syndetics->timeout : 10 - ); - } - - /** - * Create Syndetics loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getSyndetics(ServiceManager $sm) - { - return static::getAbstractSyndetics($sm, false); - } - - /** - * Create SyndeticsPlus loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getSyndeticsPlus(ServiceManager $sm) - { - return static::getAbstractSyndetics($sm, true); - } -} diff --git a/module/VuFind/src/VuFind/Content/Summaries/PluginManager.php b/module/VuFind/src/VuFind/Content/Summaries/PluginManager.php index d8ba2a673f10dae4f679c2e3e2330cbf2c9fa549..a0cae2515ddefbe7e21bee9fef4ddceb2d9d7e79 100644 --- a/module/VuFind/src/VuFind/Content/Summaries/PluginManager.php +++ b/module/VuFind/src/VuFind/Content/Summaries/PluginManager.php @@ -38,6 +38,28 @@ namespace VuFind\Content\Summaries; */ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager { + /** + * Default plugin aliases. + * + * @var array + */ + protected $aliases = [ + 'syndetics' => 'VuFind\Content\Summaries\Syndetics', + 'syndeticsplus' => 'VuFind\Content\Summaries\SyndeticsPlus', + ]; + + /** + * Default plugin factories. + * + * @var array + */ + protected $factories = [ + 'VuFind\Content\Summaries\Syndetics' => + 'VuFind\Content\AbstractSyndeticsFactory', + 'VuFind\Content\Summaries\SyndeticsPlus' => + 'VuFind\Content\AbstractSyndeticsFactory', + ]; + /** * Return the name of the base class or interface that plug-ins must conform * to. diff --git a/module/VuFind/src/VuFind/Content/TOC/Factory.php b/module/VuFind/src/VuFind/Content/TOC/Factory.php deleted file mode 100644 index 66599895f2e6ba5699bdc5d47c0e10587de4d220..0000000000000000000000000000000000000000 --- a/module/VuFind/src/VuFind/Content/TOC/Factory.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php -/** - * Factory for instantiating content loaders - * - * PHP version 5 - * - * Copyright (C) The University of Chicago 2017. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @category VuFind2 - * @package Content - * @author John Jung <jej@uchicago.edu> - * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License - * @link http://vufind.org/wiki/vufind2:developer_manual Wiki - */ -namespace VuFind\Content\TOC; - -use Zend\ServiceManager\ServiceManager; - -/** - * Factory for instantiating content loaders - * - * @category VuFind2 - * @package Content - * @author John Jung <jej@uchicago.edu> - * @license http://opensource.org/licenses/gpl-2.0.php GNU General - * Public License - * @link http://vufind.org/wiki/vufind2:developer_manual Wiki - * @codeCoverageIgnore - */ -class Factory -{ - /** - * Create either a Syndetics or SyndeticsPlus loader - * - * @param ServiceManager $sm Service manager - * @param bool $plus Instantiate in Syndetics Plus mode? - * - * @return mixed - */ - public static function getAbstractSyndetics(ServiceManager $sm, $plus) - { - $config = $sm->get('VuFind\Config')->get('config'); - return new Syndetics( - isset($config->Syndetics->use_ssl) && $config->Syndetics->use_ssl, - $plus, - isset($config->Syndetics->timeout) ? $config->Syndetics->timeout : 10 - ); - } - - /** - * Create Syndetics loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getSyndetics(ServiceManager $sm) - { - return static::getAbstractSyndetics($sm, false); - } - - /** - * Create SyndeticsPlus loader - * - * @param ServiceManager $sm Service manager - * - * @return mixed - */ - public static function getSyndeticsPlus(ServiceManager $sm) - { - return static::getAbstractSyndetics($sm, true); - } -} diff --git a/module/VuFind/src/VuFind/Content/TOC/PluginManager.php b/module/VuFind/src/VuFind/Content/TOC/PluginManager.php index 614c127a248ae64c4298e185267a9e5f9f7ab1bd..c74537ce6cccbdf88ae177e26ce589e0006fb623 100644 --- a/module/VuFind/src/VuFind/Content/TOC/PluginManager.php +++ b/module/VuFind/src/VuFind/Content/TOC/PluginManager.php @@ -38,6 +38,27 @@ namespace VuFind\Content\TOC; */ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager { + /** + * Default plugin aliases. + * + * @var array + */ + protected $aliases = [ + 'syndetics' => 'VuFind\Content\TOC\Syndetics', + 'syndeticsplus' => 'VuFind\Content\TOC\SyndeticsPlus', + ]; + + /** + * Default plugin factories. + * + * @var array + */ + protected $factories = [ + 'VuFind\Content\TOC\Syndetics' => 'VuFind\Content\AbstractSyndeticsFactory', + 'VuFind\Content\TOC\SyndeticsPlus' => + 'VuFind\Content\AbstractSyndeticsFactory', + ]; + /** * Return the name of the base class or interface that plug-ins must conform * to.