Skip to content

Commit

Permalink
Rename AJAX handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Dec 18, 2024
1 parent 7293036 commit 9926c7d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* AJAX handler to look up DOI data.
* AJAX handler to look up identifier-based link data.
*
* PHP version 8
*
Expand Down Expand Up @@ -36,15 +36,15 @@
use function count;

/**
* AJAX handler to look up DOI data.
* AJAX handler to look up identifier-based link data.
*
* @category VuFind
* @package AJAX
* @author Demian Katz <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class DoiLookup extends AbstractBase
class IdentifierLinksLookup extends AbstractBase
{
/**
* DOI Linker Plugin Manager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Factory for DoiLookup AJAX handler.
* Factory for IdentifierLinksLookup AJAX handler.
*
* PHP version 8
*
Expand Down Expand Up @@ -35,15 +35,15 @@
use Psr\Container\ContainerInterface;

/**
* Factory for DoiLookup AJAX handler.
* Factory for IdentifierLinksLookup AJAX handler.
*
* @category VuFind
* @package AJAX
* @author Demian Katz <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class DoiLookupFactory implements \Laminas\ServiceManager\Factory\FactoryInterface
class IdentifierLinksLookupFactory implements \Laminas\ServiceManager\Factory\FactoryInterface
{
/**
* Create an object
Expand Down
4 changes: 2 additions & 2 deletions module/VuFind/src/VuFind/AjaxHandler/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
'checkRequestIsValid' => CheckRequestIsValid::class,
'commentRecord' => CommentRecord::class,
'deleteRecordComment' => DeleteRecordComment::class,
'doiLookup' => DoiLookup::class,
'identifierLinksLookup' => IdentifierLinksLookup::class,
'getACSuggestions' => GetACSuggestions::class,
'getIlsStatus' => GetIlsStatus::class,
'getItemStatuses' => GetItemStatuses::class,
Expand Down Expand Up @@ -90,7 +90,7 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
CheckRequestIsValid::class => AbstractIlsAndUserActionFactory::class,
CommentRecord::class => CommentRecordFactory::class,
DeleteRecordComment::class => DeleteRecordCommentFactory::class,
DoiLookup::class => DoiLookupFactory::class,
IdentifierLinksLookup::class => IdentifierLinksLookupFactory::class,
GetACSuggestions::class => GetACSuggestionsFactory::class,
GetIlsStatus::class => GetIlsStatusFactory::class,
GetItemStatuses::class => GetItemStatusesFactory::class,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* DoiLookup test class.
* IdentifierLinksLookup test class.
*
* PHP version 8
*
Expand Down Expand Up @@ -30,21 +30,21 @@
namespace VuFindTest\AjaxHandler;

use Laminas\View\Renderer\PhpRenderer;
use VuFind\AjaxHandler\DoiLookup;
use VuFind\AjaxHandler\DoiLookupFactory;
use VuFind\AjaxHandler\IdentifierLinksLookup;
use VuFind\AjaxHandler\IdentifierLinksLookupFactory;
use VuFind\DoiLinker\DoiLinkerInterface;
use VuFind\DoiLinker\PluginManager;

/**
* DoiLookup test class.
* IdentifierLinksLookup test class.
*
* @category VuFind
* @package Tests
* @author Demian Katz <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Page
*/
class DoiLookupTest extends \VuFindTest\Unit\AjaxHandlerTestCase
class IdentifierLinksLookupTest extends \VuFindTest\Unit\AjaxHandlerTestCase
{
use \VuFindTest\Feature\ConfigPluginManagerTrait;

Expand Down Expand Up @@ -83,19 +83,17 @@ protected function getMockPlugin(
->createMock(DoiLinkerInterface::class, ['getLinks']);
$mockPlugin->expects($this->$times())->method('getLinks')
->with($this->equalTo($expected))
->will(
$this->returnValue(
[
$doi => [
[
'link' => 'http://' . $value,
'label' => $value,
'icon' => 'remote-icon',
'localIcon' => 'local-icon',
],
->willReturn(
[
$doi => [
[
'link' => 'http://' . $value,
'label' => $value,
'icon' => 'remote-icon',
'localIcon' => 'local-icon',
],
]
)
],
]
);
return $mockPlugin;
}
Expand Down Expand Up @@ -149,8 +147,8 @@ function ($plugin) use ($plugins) {

$this->container->set('ViewRenderer', $mockRenderer);

$factory = new DoiLookupFactory();
$handler = $factory($this->container, DoiLookup::class);
$factory = new IdentifierLinksLookupFactory();
$handler = $factory($this->container, IdentifierLinksLookup::class);
$params = $this->getParamsHelper(['doi' => $requested]);
return $handler->handleRequest($params);
}
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap3/js/identifierLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ VuFind.register('identifierLinks', function identifierLinks() {
if (Object.keys(postBody).length === 0) {
return;
}
queryParams.set("method", "doiLookup");
queryParams.set("method", "identifierLinksLookup");
var url = VuFind.path + '/AJAX/JSON?' + queryParams.toString();
fetch(url, { method: "POST", body: JSON.stringify(postBody) })
.then(function embedIdentifierLinksDone(rawResponse) {
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap5/js/identifierLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ VuFind.register('identifierLinks', function identifierLinks() {
if (Object.keys(postBody).length === 0) {
return;
}
queryParams.set("method", "doiLookup");
queryParams.set("method", "identifierLinksLookup");
var url = VuFind.path + '/AJAX/JSON?' + queryParams.toString();
fetch(url, { method: "POST", body: JSON.stringify(postBody) })
.then(function embedIdentifierLinksDone(rawResponse) {
Expand Down

0 comments on commit 9926c7d

Please sign in to comment.