Skip to content

Commit af7b025

Browse files
committed
Move query from Response to SearchRetrieveResponse, and make version check generic
1 parent fb16689 commit af7b025

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/Response.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ class Response implements ResponseInterface {
2222
/** @var string SRU protocol version */
2323
public $version;
2424

25-
/** @var string The CQL query used to generate the response */
26-
public $query;
27-
2825
/**
2926
* Create a new response
3027
*
@@ -40,23 +37,17 @@ public function __construct($text, &$client = null)
4037

4138
$this->client = $client;
4239

43-
$doc->registerXPathNamespaces(array(
40+
$this->response->registerXPathNamespaces(array(
4441
'srw' => 'http://www.loc.gov/zing/srw/',
4542
'd' => 'http://www.loc.gov/zing/srw/diagnostic/'
4643
));
4744

48-
$this->version = $doc->text('/srw:searchRetrieveResponse/srw:version');
45+
$this->version = $this->response->text('/srw:*/srw:version');
4946

50-
$e = $doc->first('/srw:searchRetrieveResponse/srw:diagnostics');
47+
$e = $this->response->first('/srw:*/srw:diagnostics');
5148
if ($e) {
5249
$this->error = $e->text('d:diagnostic/d:message') . '. ' . $e->text('d:diagnostic/d:details');
5350
}
54-
55-
// The server may echo the request back to the client along with the response
56-
$this->query = $doc->text('/srw:searchRetrieveResponse/srw:echoedSearchRetrieveRequest/srw:query') ?: null;
57-
58-
$this->response = $doc;
59-
6051
}
6152

6253
/**

src/SearchRetrieveResponse.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class SearchRetrieveResponse extends Response implements ResponseInterface {
1616
/** @var int Position of next record in the result set, or null if no such record exist */
1717
public $nextRecordPosition;
1818

19+
/** @var string The CQL query used to generate the response */
20+
public $query;
21+
1922
/**
2023
* Create a new searchRetrieve response
2124
*
@@ -29,6 +32,9 @@ public function __construct($text, &$client = null)
2932
$this->numberOfRecords = (int) $this->response->text('/srw:searchRetrieveResponse/srw:numberOfRecords');
3033
$this->nextRecordPosition = (int) $this->response->text('/srw:searchRetrieveResponse/srw:nextRecordPosition') ?: null;
3134

35+
// The server may echo the request back to the client along with the response
36+
$this->query = $this->response->text('/srw:searchRetrieveResponse/srw:echoedSearchRetrieveRequest/srw:query') ?: null;
37+
3238
$this->records = array();
3339
foreach ($this->response->xpath('/srw:searchRetrieveResponse/srw:records/srw:record') as $record) {
3440
$this->records[] = new Record($record);

0 commit comments

Comments
 (0)