Skip to content
Snippets Groups Projects
Commit 31888337 authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Refactor CQL escaping to a support method.

parent 5c36bfdf
No related merge requests found
......@@ -316,6 +316,18 @@ class Folio extends AbstractAPI implements
throw new \Exception('Unsupported ID type: ' . $idType);
}
/**
* Escape a string for use in a CQL query.
*
* @param string $in Input string
*
* @return string
*/
protected function escapeCql($in)
{
return str_replace('"', '\"', str_replace('&', '%26', $in));
}
/**
* Retrieve FOLIO instance using VuFind's chosen bibliographic identifier.
*
......@@ -332,8 +344,9 @@ class Folio extends AbstractAPI implements
$idType = $this->getBibIdType();
$idField = $idType === 'instance' ? 'id' : $idType;
$escaped = str_replace('"', '\"', str_replace('&', '%26', $bibId));
$query = ['query' => '(' . $idField . '=="' . $escaped . '")'];
$query = [
'query' => '(' . $idField . '=="' . $this->escapeCql($bibId) . '")'
];
$response = $this->makeRequest('GET', '/instance-storage/instances', $query);
$instances = json_decode($response->getBody());
if (count($instances->instances) == 0) {
......
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