diff --git a/module/finc/src/finc/ILS/Driver/FincLibero.php b/module/finc/src/finc/ILS/Driver/FincLibero.php index bca8dc110f63d820cbfd99d7629f70c3c60c123a..2ad8a9f2e22a0e84bfb716eef18133f7cd17d683 100644 --- a/module/finc/src/finc/ILS/Driver/FincLibero.php +++ b/module/finc/src/finc/ILS/Driver/FincLibero.php @@ -483,17 +483,7 @@ class FincLibero extends FincILS implements TranslatorAwareInterface { $return = parent::getItemStatus($item); - // add all item specific information from DAIA field about to item_notes - // (https://intern.finc.info/issues/7863) - $about = (isset($item['about'])) ? [$item['about']] : []; - - $return['item_notes'] = array_unique( - array_merge( - (array) $return['status'], - $return['item_notes'], - $about - ) - ); + $return['item_notes'] = $this->getItemNotes($return, $item); $return['awlRecordId'] = $this->getBoundItemId($item); // is this item bound with another item? @@ -516,9 +506,49 @@ class FincLibero extends FincILS implements TranslatorAwareInterface } } + $return['service_type'] = $this->_reduceServices($return['services']); + return $return; } + /** + * Helper function for getItemStatus(). + * Gather all item notes from current (parent) result and DAIA item + * + * @param array $return intermediate result from parent::getItemStatus() + * @param array $item DAIA item + * @return array 'item_notes' part for result + */ + protected function getItemNotes($return, $item) + { + // add all item specific information from DAIA field about to item_notes + // (https://intern.finc.info/issues/7863) + return array_unique( + array_merge( + (array)$return['status'], + $return['item_notes'], + $item['about'] ?? [] + ) + ); + } + + /** + * Helper function for 'service_type' entry in getItemStatus + * + * @param array $services actually present services in DAIA item + * @return false|int|mixed preferred service if present or 0 + */ + protected function _reduceServices($services) + { + $prio = [ + 'loan', + 'presentation', + ]; + $res = array_intersect($prio, $services); + if (empty($res)) return 0; + else return current($res); + } + /** * Helper function to return an appropriate status string for current item *