diff --git a/module/VuFind/src/VuFind/ILS/Driver/Folio.php b/module/VuFind/src/VuFind/ILS/Driver/Folio.php index 958e203ee05115e8b0daa0b556a3b256ba217b5e..cede35e4eceb086188ff7ae10cbb678ca756d028 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Folio.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Folio.php @@ -416,6 +416,36 @@ class Folio extends AbstractAPI implements ); } + /** + * Gets the location name from the /locations endpoint and sets + * the display name to discoveryDisplayName, name, or code + * based on whichever is available first in that order. + * + * @param string $locationId ID of a location from the + * /holdings-storage/holdings endpoint + * + * @return string + */ + protected function getLocationName($locationId) + { + $locationName = ''; + if (!empty($locationId)) { + $locationResponse = $this->makeRequest( + 'GET', + '/locations/' . $locationId + ); + $location = json_decode($locationResponse->getBody()); + if (!empty($location->discoveryDisplayName)) { + $locationName = $location->discoveryDisplayName; + } elseif (!empty($location->name)) { + $locationName = $location->name; + } elseif (!empty($location->code)) { + $locationName = $location->code; + } + } + return $locationName; + } + /** * This method queries the ILS for holding information. * @@ -442,15 +472,8 @@ class Folio extends AbstractAPI implements $holdingBody = json_decode($holdingResponse->getBody()); $items = []; foreach ($holdingBody->holdingsRecords as $holding) { - $locationName = ''; - if (!empty($holding->permanentLocationId)) { - $locationResponse = $this->makeRequest( - 'GET', - '/locations/' . $holding->permanentLocationId - ); - $location = json_decode($locationResponse->getBody()); - $locationName = $location->name; - } + $locationId = $holding->permanentLocationId; + $locationName = $this->getLocationName($locationId); $query = [ 'query' => '(holdingsRecordId=="' . $holding->id