diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index d06c0c3d4d2..9da9f13985b 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -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', @@ -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', @@ -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 */], diff --git a/module/VuFind/src/VuFind/AjaxHandler/IdentifierLinksLookup.php b/module/VuFind/src/VuFind/AjaxHandler/IdentifierLinksLookup.php index 8e5bbb473fe..b6eb0cb3bca 100644 --- a/module/VuFind/src/VuFind/AjaxHandler/IdentifierLinksLookup.php +++ b/module/VuFind/src/VuFind/AjaxHandler/IdentifierLinksLookup.php @@ -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; diff --git a/module/VuFind/src/VuFind/AjaxHandler/IdentifierLinksLookupFactory.php b/module/VuFind/src/VuFind/AjaxHandler/IdentifierLinksLookupFactory.php index ba3a7cf7a39..e11e07da239 100644 --- a/module/VuFind/src/VuFind/AjaxHandler/IdentifierLinksLookupFactory.php +++ b/module/VuFind/src/VuFind/AjaxHandler/IdentifierLinksLookupFactory.php @@ -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 ); diff --git a/module/VuFind/src/VuFind/DoiLinker/Demo.php b/module/VuFind/src/VuFind/DoiLinker/Demo.php index 422efab4518..17274c47245 100644 --- a/module/VuFind/src/VuFind/DoiLinker/Demo.php +++ b/module/VuFind/src/VuFind/DoiLinker/Demo.php @@ -27,7 +27,7 @@ * @link https://vufind.org/wiki/development:plugins:doi_linkers Wiki */ -namespace VuFind\DoiLinker; +namespace VuFind\IdentifierLinker; use function count; @@ -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 diff --git a/module/VuFind/src/VuFind/DoiLinker/BrowZine.php b/module/VuFind/src/VuFind/IdentifierLinker/BrowZine.php similarity index 98% rename from module/VuFind/src/VuFind/DoiLinker/BrowZine.php rename to module/VuFind/src/VuFind/IdentifierLinker/BrowZine.php index b5af60fdc1f..981ef0fcb93 100644 --- a/module/VuFind/src/VuFind/DoiLinker/BrowZine.php +++ b/module/VuFind/src/VuFind/IdentifierLinker/BrowZine.php @@ -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; @@ -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; diff --git a/module/VuFind/src/VuFind/DoiLinker/BrowZineFactory.php b/module/VuFind/src/VuFind/IdentifierLinker/BrowZineFactory.php similarity index 98% rename from module/VuFind/src/VuFind/DoiLinker/BrowZineFactory.php rename to module/VuFind/src/VuFind/IdentifierLinker/BrowZineFactory.php index fb59933e0e4..6b3f80d0bba 100644 --- a/module/VuFind/src/VuFind/DoiLinker/BrowZineFactory.php +++ b/module/VuFind/src/VuFind/IdentifierLinker/BrowZineFactory.php @@ -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; diff --git a/module/VuFind/src/VuFind/IdentifierLinker/Demo.php b/module/VuFind/src/VuFind/IdentifierLinker/Demo.php new file mode 100644 index 00000000000..17274c47245 --- /dev/null +++ b/module/VuFind/src/VuFind/IdentifierLinker/Demo.php @@ -0,0 +1,82 @@ + + * @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 + * @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; + } +} diff --git a/module/VuFind/src/VuFind/DoiLinker/DoiLinkerInterface.php b/module/VuFind/src/VuFind/IdentifierLinker/IdentifierLinkerInterface.php similarity index 96% rename from module/VuFind/src/VuFind/DoiLinker/DoiLinkerInterface.php rename to module/VuFind/src/VuFind/IdentifierLinker/IdentifierLinkerInterface.php index e11708fd055..2a679c54c9f 100644 --- a/module/VuFind/src/VuFind/DoiLinker/DoiLinkerInterface.php +++ b/module/VuFind/src/VuFind/IdentifierLinker/IdentifierLinkerInterface.php @@ -27,7 +27,7 @@ * @link https://vufind.org/wiki/development:plugins:record_drivers Wiki */ -namespace VuFind\DoiLinker; +namespace VuFind\IdentifierLinker; /** * DOI linker interface @@ -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 diff --git a/module/VuFind/src/VuFind/DoiLinker/PluginManager.php b/module/VuFind/src/VuFind/IdentifierLinker/PluginManager.php similarity index 96% rename from module/VuFind/src/VuFind/DoiLinker/PluginManager.php rename to module/VuFind/src/VuFind/IdentifierLinker/PluginManager.php index 055c485a7e8..b6a9ad29108 100644 --- a/module/VuFind/src/VuFind/DoiLinker/PluginManager.php +++ b/module/VuFind/src/VuFind/IdentifierLinker/PluginManager.php @@ -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; @@ -72,6 +72,6 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager */ protected function getExpectedInterface() { - return DoiLinkerInterface::class; + return IdentifierLinkerInterface::class; } } diff --git a/module/VuFind/src/VuFind/DoiLinker/Unpaywall.php b/module/VuFind/src/VuFind/IdentifierLinker/Unpaywall.php similarity index 98% rename from module/VuFind/src/VuFind/DoiLinker/Unpaywall.php rename to module/VuFind/src/VuFind/IdentifierLinker/Unpaywall.php index 2abf967c168..009a7c0abeb 100644 --- a/module/VuFind/src/VuFind/DoiLinker/Unpaywall.php +++ b/module/VuFind/src/VuFind/IdentifierLinker/Unpaywall.php @@ -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; @@ -42,7 +42,7 @@ * @link https://vufind.org/wiki/development:plugins:doi_linkers Wiki */ class Unpaywall implements - DoiLinkerInterface, + IdentifierLinkerInterface, TranslatorAwareInterface, HttpServiceAwareInterface { diff --git a/module/VuFind/src/VuFind/DoiLinker/UnpaywallFactory.php b/module/VuFind/src/VuFind/IdentifierLinker/UnpaywallFactory.php similarity index 98% rename from module/VuFind/src/VuFind/DoiLinker/UnpaywallFactory.php rename to module/VuFind/src/VuFind/IdentifierLinker/UnpaywallFactory.php index 5b1bb079798..8aeecfba423 100644 --- a/module/VuFind/src/VuFind/DoiLinker/UnpaywallFactory.php +++ b/module/VuFind/src/VuFind/IdentifierLinker/UnpaywallFactory.php @@ -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; diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/AjaxHandler/IdentifierLinksLookupTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/AjaxHandler/IdentifierLinksLookupTest.php index fefa86da100..887a0b7c9ec 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/AjaxHandler/IdentifierLinksLookupTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/AjaxHandler/IdentifierLinksLookupTest.php @@ -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. @@ -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, @@ -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( diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/DoiLinker/BrowZineTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/IdentifierLinker/BrowZineTest.php similarity index 98% rename from module/VuFind/tests/unit-tests/src/VuFindTest/DoiLinker/BrowZineTest.php rename to module/VuFind/tests/unit-tests/src/VuFindTest/IdentifierLinker/BrowZineTest.php index 7011de8de0e..d49653ee988 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/DoiLinker/BrowZineTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/IdentifierLinker/BrowZineTest.php @@ -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; diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/DoiLinker/UnpaywallTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/IdentifierLinker/UnpaywallTest.php similarity index 97% rename from module/VuFind/tests/unit-tests/src/VuFindTest/DoiLinker/UnpaywallTest.php rename to module/VuFind/tests/unit-tests/src/VuFindTest/IdentifierLinker/UnpaywallTest.php index 3852e4119f9..262df6893b1 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/DoiLinker/UnpaywallTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/IdentifierLinker/UnpaywallTest.php @@ -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