Skip to content

Commit 4e6ed84

Browse files
committed
Change the logic to check for get this compatibility
1 parent 6f016eb commit 4e6ed84

8 files changed

Lines changed: 24 additions & 45 deletions

File tree

module/VuFind/src/VuFind/AjaxHandler/GetItemStatuses.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,6 @@ public function handleRequest(Params $params)
518518
];
519519
}
520520
}
521-
if (!$this->ils->getDriver()->supportsGetThis()) {
522-
$this->getThis = null;
523-
}
524521

525522
if (!is_array($results)) {
526523
// If getStatuses returned garbage, let's turn it into an empty array

module/VuFind/src/VuFind/GetThis/GetThisLoader.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Exception;
1818
use Throwable;
1919
use VuFind\Config\YamlReader;
20+
use VuFind\ILS\Logic\AvailabilityStatusInterface;
2021
use VuFind\Log\LoggerAwareTrait;
2122
use VuFind\Regex\Regex;
2223
use VuFind\View\Helper\Root\Translate;
@@ -762,4 +763,25 @@ public function setItemId(?string $itemId): void
762763
}
763764
$this->subTemplates = null;
764765
}
766+
767+
/**
768+
* Given holdings, return whether the holdings are compatible with the get this feature
769+
*
770+
* @param array $items Holdings
771+
*
772+
* @return bool
773+
*/
774+
public function areItemsSupported(array $items): bool
775+
{
776+
foreach ($items as $item) {
777+
if (
778+
array_key_exists('location', $item)
779+
|| array_key_exists('location_code', $item)
780+
|| (array_key_exists('availability', $item) && $item['availability'] instanceof AvailabilityStatusInterface)
781+
) {
782+
return true;
783+
}
784+
}
785+
return false;
786+
}
765787
}

module/VuFind/src/VuFind/ILS/Driver/AbstractBase.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,4 @@ protected function throwAsIlsException(
8181
): void {
8282
throw new ILSException($msg ?? $exception->getMessage(), 0, $exception);
8383
}
84-
85-
/**
86-
* Whether the driver supports the GetThis feature
87-
*
88-
* @return bool
89-
*/
90-
public function supportsGetThis(): bool
91-
{
92-
return false;
93-
}
9484
}

module/VuFind/src/VuFind/ILS/Driver/Demo.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,14 +2906,4 @@ public function getUrlsForRecord(string $id): array
29062906
}
29072907
return $links;
29082908
}
2909-
2910-
/**
2911-
* Whether the driver supports the GetThis feature
2912-
*
2913-
* @return bool
2914-
*/
2915-
public function supportsGetThis(): bool
2916-
{
2917-
return true;
2918-
}
29192909
}

module/VuFind/src/VuFind/ILS/Driver/Folio.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,14 +2767,4 @@ public function getNewItems($page, $limit, $daysOld, $fundId = null)
27672767
{
27682768
return [];
27692769
}
2770-
2771-
/**
2772-
* Whether the driver supports the GetThis feature
2773-
*
2774-
* @return bool
2775-
*/
2776-
public function supportsGetThis(): bool
2777-
{
2778-
return true;
2779-
}
27802770
}

module/VuFind/src/VuFind/RecordTab/HoldingsILS.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,4 @@ public function getPaginator($totalItemCount, $page, $itemLimit)
205205

206206
return $paginator;
207207
}
208-
209-
/**
210-
* Whether the driver supports the GetThis feature
211-
*
212-
* @return bool
213-
*/
214-
public function supportsGetThis(): bool
215-
{
216-
return $this->catalog->getDriver()->supportsGetThis();
217-
}
218208
}

themes/bootstrap5/templates/RecordTab/holdingsils/standard.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
$checkStorageRetrievalRequest = $holding['checkStorageRetrievalRequest'] ?? false;
55
$checkILLRequest = $holding['checkILLRequest'] ?? false;
66
$availabilityStatus = $holding['availability'];
7-
$getThisEnabled = isset($this->getThis) && $this->tab->supportsGetThis();
7+
$getThisEnabled = isset($this->getThis) && $this->getThis->areItemsSupported([$holding]);
88
if ($getThisEnabled) {
99
$this->getThis->setItems([$holding]);
1010
$this->getThis->setRecord($this->record($this->driver));

themes/bootstrap5/templates/ajax/status-full.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
$getThisEnabled = isset($this->getThis);
2+
$getThisEnabled = isset($this->getThis) && $this->getThis->areItemsSupported($this->statusItems);
33
if ($getThisEnabled) {
44
$this->getThis->setItems($this->statusItems);
55
}

0 commit comments

Comments
 (0)