Skip to content
Snippets Groups Projects
Commit 9440a64a authored by Ere Maijala's avatar Ere Maijala Committed by Robert Lange
Browse files

Make holdings retrieval preserve any custom array elements. (#1590)

parent 381ba8f0
No related merge requests found
...@@ -1056,13 +1056,23 @@ class Connection implements TranslatorAwareInterface, LoggerAwareInterface ...@@ -1056,13 +1056,23 @@ class Connection implements TranslatorAwareInterface, LoggerAwareInterface
$holdings = $this->__call('getHolding', [$id, $patron, $finalOptions]); $holdings = $this->__call('getHolding', [$id, $patron, $finalOptions]);
// Return all the necessary details: // Return all the necessary details:
return [ if (!isset($holdings['holdings'])) {
'total' => $holdings['total'] ?? count($holdings), $holdings = [
'holdings' => $holdings['holdings'] ?? $holdings, 'total' => count($holdings),
'electronic_holdings' => $holdings['electronic_holdings'] ?? [], 'holdings' => $holdings,
'page' => $finalOptions['page'], 'electronic_holdings' => [],
'itemLimit' => $finalOptions['itemLimit'], ];
]; } else {
if (!isset($holdings['total'])) {
$holdings['total'] = count($holdings['holdings']);
}
if (!isset($holdings['electronic_holdings'])) {
$holdings['electronic_holdings'] = [];
}
}
$holdings['page'] = $finalOptions['page'];
$holdings['itemLimit'] = $finalOptions['itemLimit'];
return $holdings;
} }
/** /**
......
...@@ -173,70 +173,68 @@ class Holds ...@@ -173,70 +173,68 @@ class Holds
* Public method for getting item holdings from the catalog and selecting which * Public method for getting item holdings from the catalog and selecting which
* holding method to call * holding method to call
* *
* @param string $id A Bib ID * @param string $id A Bib ID
* @param array $ids A list of Source Records (if catalog is for a consortium) * @param array $ids A list of Source Records (if catalog is for a
* consortium)
* @param array $options Optional options to pass on to getHolding()
* *
* @return array A sorted results set * @return array A sorted results set
*/ */
public function getHoldings($id, $ids = null) public function getHoldings($id, $ids = null, $options = [])
{ {
$holdings = []; if (!$this->catalog) {
return [];
}
// Retrieve stored patron credentials; it is the responsibility of the
// controller and view to inform the user that these credentials are
// needed for hold data.
try {
$patron = $this->ilsAuth->storedCatalogLogin();
// Does this ILS Driver handle consortial holdings?
$config = $this->catalog->checkFunction(
'Holds', compact('id', 'patron')
);
} catch (ILSException $e) {
$patron = false;
$config = [];
}
// Get Holdings Data if (isset($config['consortium']) && $config['consortium'] == true) {
if ($this->catalog) { $result = $this->catalog->getConsortialHoldings(
// Retrieve stored patron credentials; it is the responsibility of the $id, $patron ? $patron : null, $ids
// controller and view to inform the user that these credentials are );
// needed for hold data. } else {
try { $result = $this->catalog
$patron = $this->ilsAuth->storedCatalogLogin(); ->getHolding($id, $patron ? $patron : null, $options);
}
// Does this ILS Driver handle consortial holdings?
$config = $this->catalog->checkFunction(
'Holds', compact('id', 'patron')
);
} catch (ILSException $e) {
$patron = false;
$config = [];
}
if (isset($config['consortium']) && $config['consortium'] == true) { $grb = 'getRequestBlocks'; // use variable to shorten line below:
$result = $this->catalog->getConsortialHoldings( $blocks
$id, $patron ? $patron : null, $ids = $patron && $this->catalog->checkCapability($grb, compact('patron'))
); ? $this->catalog->getRequestBlocks($patron) : false;
} else {
$result = $this->catalog->getHolding($id, $patron ? $patron : null); $mode = $this->catalog->getHoldsMode();
}
$grb = 'getRequestBlocks'; // use variable to shorten line below: if ($mode == "disabled") {
$blocks $holdings = $this->standardHoldings($result);
= $patron && $this->catalog->checkCapability($grb, compact('patron')) } elseif ($mode == "driver") {
? $this->catalog->getRequestBlocks($patron) : false; $holdings = $this->driverHoldings($result, $config, !empty($blocks));
} else {
$holdings = $this->generateHoldings($result, $mode, $config);
}
$mode = $this->catalog->getHoldsMode(); $holdings = $this->processStorageRetrievalRequests(
$holdings, $id, $patron, !empty($blocks)
);
$holdings = $this->processILLRequests(
$holdings, $id, $patron, !empty($blocks)
);
if ($mode == "disabled") { $result['blocks'] = $blocks;
$holdings = $this->standardHoldings($result); $result['holdings'] = $this->formatHoldings($holdings);
} elseif ($mode == "driver") {
$holdings = $this->driverHoldings($result, $config, !empty($blocks));
} else {
$holdings = $this->generateHoldings($result, $mode, $config);
}
$holdings = $this->processStorageRetrievalRequests( return $result;
$holdings, $id, $patron, !empty($blocks)
);
$holdings = $this->processILLRequests(
$holdings, $id, $patron, !empty($blocks)
);
}
return [
'blocks' => $blocks,
'total' => $result['total'],
'page' => $result['page'],
'itemLimit' => $result['itemLimit'],
'holdings' => $this->formatHoldings($holdings),
'electronic_holdings' => $result['electronic_holdings'] ?? [],
];
} }
/** /**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment