Skip to content

Commit

Permalink
Rename plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Dec 18, 2024
1 parent c2aaf3c commit 6ead6ba
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 24 deletions.
4 changes: 2 additions & 2 deletions module/VuFind/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@
'VuFind\Db\Service\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'VuFind\Db\Table\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'VuFind\DigitalContent\OverdriveConnector' => 'VuFind\DigitalContent\OverdriveConnectorFactory',
'VuFind\DoiLinker\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'VuFind\Escaper\Escaper' => 'VuFind\Escaper\EscaperFactory',
'VuFind\Export' => 'VuFind\ExportFactory',
'VuFind\Favorites\FavoritesService' => 'VuFind\Favorites\FavoritesServiceFactory',
Expand All @@ -472,6 +471,7 @@
'VuFind\Http\PhpEnvironment\Request' => 'Laminas\ServiceManager\Factory\InvokableFactory',
'VuFind\I18n\Locale\LocaleSettings' => 'VuFind\Service\ServiceWithConfigIniFactory',
'VuFind\I18n\Sorter' => 'VuFind\I18n\SorterFactory',
'VuFind\IdentifierLinker\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'VuFind\ILS\Connection' => 'VuFind\ILS\ConnectionFactory',
'VuFind\ILS\Driver\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'VuFind\ILS\Logic\AvailabilityStatusManager' => 'Laminas\ServiceManager\Factory\InvokableFactory',
Expand Down Expand Up @@ -694,12 +694,12 @@
'db_row' => [ /* see VuFind\Db\Row\PluginManager for defaults */ ],
'db_service' => [ /* see VuFind\Db\Service\PluginManager for defaults */ ],
'db_table' => [ /* see VuFind\Db\Table\PluginManager for defaults */ ],
'doilinker' => [ /* see VuFind\DoiLinker\PluginManager for defaults */ ],
'form_handler' => [ /* see VuFind\Form\Handler\PluginManager for defaults */],
'hierarchy_driver' => [ /* see VuFind\Hierarchy\Driver\PluginManager for defaults */ ],
'hierarchy_treedataformatter' => [ /* see VuFind\Hierarchy\TreeDataFormatter\PluginManager for defaults */ ],
'hierarchy_treedatasource' => [ /* see VuFind\Hierarchy\TreeDataSource\PluginManager for defaults */ ],
'hierarchy_treerenderer' => [ /* see VuFind\Hierarchy\TreeRenderer\PluginManager for defaults */ ],
'identifierlinker' => [ /* see VuFind\IdentifierLinker\PluginManager for defaults */ ],
'ils_driver' => [ /* See VuFind\ILS\Driver\PluginManager for defaults */ ],
'metadatavocabulary' => [ /* See VuFind\MetadataVocabulary\PluginManager for defaults */],
'navigation' => [ /* See VuFind\Navigation\PluginManager for defaults */],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

use Laminas\Mvc\Controller\Plugin\Params;
use Laminas\View\Renderer\RendererInterface;
use VuFind\DoiLinker\PluginManager;
use VuFind\IdentifierLinker\PluginManager;

use function count;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function __invoke(
$config = $container->get(\VuFind\Config\PluginManager::class)
->get('config')->toArray();
return new $requestedName(
$container->get(\VuFind\DoiLinker\PluginManager::class),
$container->get(\VuFind\IdentifierLinker\PluginManager::class),
$container->get('ViewRenderer'),
$config
);
Expand Down
4 changes: 2 additions & 2 deletions module/VuFind/src/VuFind/DoiLinker/Demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @link https://vufind.org/wiki/development:plugins:doi_linkers Wiki
*/

namespace VuFind\DoiLinker;
namespace VuFind\IdentifierLinker;

use function count;

Expand All @@ -40,7 +40,7 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:doi_linkers Wiki
*/
class Demo implements DoiLinkerInterface
class Demo implements IdentifierLinkerInterface
{
/**
* Possible icon values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
*/

namespace VuFind\DoiLinker;
namespace VuFind\IdentifierLinker;

use VuFind\I18n\Translator\TranslatorAwareInterface;
use VuFindSearch\Backend\BrowZine\Command\LookupDoiCommand;
Expand All @@ -44,7 +44,7 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
*/
class BrowZine implements DoiLinkerInterface, TranslatorAwareInterface
class BrowZine implements IdentifierLinkerInterface, TranslatorAwareInterface
{
use \VuFind\I18n\Translator\TranslatorAwareTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
*/

namespace VuFind\DoiLinker;
namespace VuFind\IdentifierLinker;

use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Laminas\ServiceManager\Exception\ServiceNotFoundException;
Expand Down
82 changes: 82 additions & 0 deletions module/VuFind/src/VuFind/IdentifierLinker/Demo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

/**
* Demo (fake data) DOI linker
*
* PHP version 8
*
* Copyright (C) Villanova University 2023.
*
* 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 DOI
* @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:doi_linkers Wiki
*/

namespace VuFind\IdentifierLinker;

use function count;

/**
* Demo (fake data) DOI linker
*
* @category VuFind
* @package DOI
* @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:doi_linkers Wiki
*/
class Demo implements IdentifierLinkerInterface
{
/**
* Possible icon values
*
* @var array
*/
protected $icons = ['browzine-issue', 'browzine-pdf', null];

/**
* Given an array of identifier arrays, perform a lookup and return an associative array
* of arrays, matching the keys of the input array. Each output array contains one or more
* associative arrays with required 'link' (URL to related resource) and 'label' (display text)
* keys and an optional 'icon' (URL to icon graphic) or localIcon (name of configured icon in
* theme) key.
*
* @param array[] $idArray Identifiers to look up
*
* @return array
*/
public function getLinks(array $idArray)
{
$response = [];
$supportedIdTypes = ['doi', 'isbn', 'issn'];
foreach ($idArray as $key => $ids) {
foreach ($supportedIdTypes as $type) {
if ($id = $ids[$type] ?? null) {
$icon = $this->icons[rand(0, count($this->icons) - 1)];
$response[$key][] = [
'link' => 'https://vufind.org',
'label' => 'Demonstrating ' . strtoupper($type) . " link for $id with icon "
. ($icon ?? '[null]'),
'localIcon' => $icon,
];
}
}
}
return $response;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
*/

namespace VuFind\DoiLinker;
namespace VuFind\IdentifierLinker;

/**
* DOI linker interface
Expand All @@ -38,7 +38,7 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
*/
interface DoiLinkerInterface
interface IdentifierLinkerInterface
{
/**
* Given an array of DOIs, perform a lookup and return an associative array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
*/

namespace VuFind\DoiLinker;
namespace VuFind\IdentifierLinker;

use Laminas\ServiceManager\Factory\InvokableFactory;

Expand Down Expand Up @@ -72,6 +72,6 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
*/
protected function getExpectedInterface()
{
return DoiLinkerInterface::class;
return IdentifierLinkerInterface::class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @link https://vufind.org/wiki/development:plugins:doi_linkers Wiki
*/

namespace VuFind\DoiLinker;
namespace VuFind\IdentifierLinker;

use VuFind\I18n\Translator\TranslatorAwareInterface;
use VuFindHttp\HttpServiceAwareInterface;
Expand All @@ -42,7 +42,7 @@
* @link https://vufind.org/wiki/development:plugins:doi_linkers Wiki
*/
class Unpaywall implements
DoiLinkerInterface,
IdentifierLinkerInterface,
TranslatorAwareInterface,
HttpServiceAwareInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @link https://vufind.org/wiki/development:plugins:doi_linkers Wiki
*/

namespace VuFind\DoiLinker;
namespace VuFind\IdentifierLinker;

use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Laminas\ServiceManager\Exception\ServiceNotFoundException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
use Laminas\View\Renderer\PhpRenderer;
use VuFind\AjaxHandler\IdentifierLinksLookup;
use VuFind\AjaxHandler\IdentifierLinksLookupFactory;
use VuFind\DoiLinker\DoiLinkerInterface;
use VuFind\DoiLinker\PluginManager;
use VuFind\IdentifierLinker\IdentifierLinkerInterface;
use VuFind\IdentifierLinker\PluginManager;

/**
* IdentifierLinksLookup test class.
Expand Down Expand Up @@ -71,7 +71,7 @@ protected function setupConfig($config)
* @param string $doi What DOI does this handler return data for?
* @param array $expected What is the expected DOI request?
*
* @return DoiLinkerInterface
* @return IdentifierLinkerInterface
*/
protected function getMockPlugin(
$value,
Expand All @@ -80,7 +80,7 @@ protected function getMockPlugin(
$expected = ['bar']
) {
$mockPlugin = $this->container
->createMock(DoiLinkerInterface::class, ['getLinks']);
->createMock(IdentifierLinkerInterface::class, ['getLinks']);
$mockPlugin->expects($this->$times())->method('getLinks')
->with($this->equalTo($expected))
->willReturn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
* @link https://vufind.org/wiki/development:testing:unit_tests Wiki
*/

namespace VuFindTest\DoiLinker;
namespace VuFindTest\IdentifierLinker;

use VuFind\DoiLinker\BrowZine;
use VuFind\IdentifierLinker\BrowZine;
use VuFind\Search\BackendManager;
use VuFindSearch\Backend\BrowZine\Connector;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
* @link https://vufind.org/wiki/development:testing:unit_tests Wiki
*/

namespace VuFindTest\DoiLinker;
namespace VuFindTest\IdentifierLinker;

use Laminas\Http\Client\Adapter\Test as TestAdapter;
use Laminas\Http\Response as HttpResponse;
use VuFind\DoiLinker\Unpaywall;
use VuFind\IdentifierLinker\Unpaywall;

/**
* Unpaywall Test Class
Expand Down

0 comments on commit 6ead6ba

Please sign in to comment.