@@ -35,13 +35,13 @@ class Client {
35
35
*/
36
36
protected $ credentials ;
37
37
38
- /**
39
- * Create a new client
40
- *
41
- * @param string $url Base URL to the SRU service
42
- * @param array $options Associative array of options
43
- * @param HttpClient $httpClient
44
- */
38
+ /**
39
+ * Create a new client
40
+ *
41
+ * @param string $url Base URL to the SRU service
42
+ * @param array $options Associative array of options
43
+ * @param HttpClient $httpClient
44
+ */
45
45
public function __construct ($ url , $ options = null , $ httpClient = null )
46
46
{
47
47
$ this ->url = $ url ;
@@ -80,8 +80,8 @@ public function __construct($url, $options = null, $httpClient = null)
80
80
public function urlTo ($ cql , $ start = 1 , $ count = 10 )
81
81
{
82
82
$ qs = array (
83
- 'version ' => $ this ->version ,
84
83
'operation ' => 'searchRetrieve ' ,
84
+ 'version ' => $ this ->version ,
85
85
'recordSchema ' => $ this ->schema ,
86
86
'maximumRecords ' => $ count ,
87
87
'query ' => $ cql
@@ -97,16 +97,12 @@ public function urlTo($cql, $start = 1, $count = 10)
97
97
}
98
98
99
99
/**
100
- * Perform a searchRetrieveResponse request
100
+ * Get HTTP client configuration options (authentication, proxy, headers)
101
101
*
102
- * @param string $cql
103
- * @param int $start Start value in result set (optional)
104
- * @param int $count Number of records to request (optional)
105
- * @return Response
102
+ * @return array
106
103
*/
107
- public function search ($ cql , $ start = 1 , $ count = 10 ) {
108
-
109
- $ url = $ this ->urlTo ($ cql , $ start , $ count );
104
+ protected function getHttpOptions ()
105
+ {
110
106
$ headers = array (
111
107
'Accept ' => 'application/xml '
112
108
);
@@ -122,11 +118,46 @@ public function search($cql, $start = 1, $count = 10) {
122
118
if ($ this ->proxy ) {
123
119
$ options ['proxy ' ] = $ this ->proxy ;
124
120
}
121
+ return $ options ;
122
+ }
123
+
124
+ /**
125
+ * Perform a searchRetrieve request
126
+ *
127
+ * @param string $cql
128
+ * @param int $start Start value in result set (optional)
129
+ * @param int $count Number of records to request (optional)
130
+ * @return Response
131
+ */
132
+ public function search ($ cql , $ start = 1 , $ count = 10 ) {
133
+
134
+ $ url = $ this ->urlTo ($ cql , $ start , $ count );
135
+ $ options = $ this ->getHttpOptions ();
125
136
126
137
$ res = $ this ->httpClient ->get ($ url , $ options )->send ();
127
138
$ body = $ res ->getBody (true );
128
139
129
140
return new Response ($ body , $ this );
141
+ }
142
+
143
+ /**
144
+ * Perform an explain request
145
+ *
146
+ * @return ExplainResponse
147
+ */
148
+ public function explain () {
149
+
150
+ $ url = $ this ->url . '? ' . http_build_query (array (
151
+ 'operation ' => 'explain ' ,
152
+ 'version ' => $ this ->version ,
153
+ 'recordSchema ' => $ this ->schema
154
+ ));
155
+ $ options = $ this ->getHttpOptions ();
156
+
157
+ $ res = $ this ->httpClient ->get ($ url , $ options )->send ();
158
+ $ body = $ res ->getBody (true );
159
+
160
+ return new ExplainResponse ($ body , $ this );
130
161
131
162
}
132
163
0 commit comments