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
$holdings = $this->__call('getHolding', [$id, $patron, $finalOptions]);
// Return all the necessary details:
return [
'total' => $holdings['total'] ?? count($holdings),
'holdings' => $holdings['holdings'] ?? $holdings,
'electronic_holdings' => $holdings['electronic_holdings'] ?? [],
'page' => $finalOptions['page'],
'itemLimit' => $finalOptions['itemLimit'],
];
if (!isset($holdings['holdings'])) {
$holdings = [
'total' => count($holdings),
'holdings' => $holdings,
'electronic_holdings' => [],
];
} 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
* Public method for getting item holdings from the catalog and selecting which
* holding method to call
*
* @param string $id A Bib ID
* @param array $ids A list of Source Records (if catalog is for a consortium)
* @param string $id A Bib ID
* @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
*/
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 ($this->catalog) {
// 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 = [];
}
if (isset($config['consortium']) && $config['consortium'] == true) {
$result = $this->catalog->getConsortialHoldings(
$id, $patron ? $patron : null, $ids
);
} else {
$result = $this->catalog
->getHolding($id, $patron ? $patron : null, $options);
}
if (isset($config['consortium']) && $config['consortium'] == true) {
$result = $this->catalog->getConsortialHoldings(
$id, $patron ? $patron : null, $ids
);
} else {
$result = $this->catalog->getHolding($id, $patron ? $patron : null);
}
$grb = 'getRequestBlocks'; // use variable to shorten line below:
$blocks
= $patron && $this->catalog->checkCapability($grb, compact('patron'))
? $this->catalog->getRequestBlocks($patron) : false;
$mode = $this->catalog->getHoldsMode();
$grb = 'getRequestBlocks'; // use variable to shorten line below:
$blocks
= $patron && $this->catalog->checkCapability($grb, compact('patron'))
? $this->catalog->getRequestBlocks($patron) : false;
if ($mode == "disabled") {
$holdings = $this->standardHoldings($result);
} elseif ($mode == "driver") {
$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") {
$holdings = $this->standardHoldings($result);
} elseif ($mode == "driver") {
$holdings = $this->driverHoldings($result, $config, !empty($blocks));
} else {
$holdings = $this->generateHoldings($result, $mode, $config);
}
$result['blocks'] = $blocks;
$result['holdings'] = $this->formatHoldings($holdings);
$holdings = $this->processStorageRetrievalRequests(
$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'] ?? [],
];
return $result;
}
/**
......
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