Skip to content

Commit bb8f91e

Browse files
committed
Allowing entire kv tree to be downloaded
1 parent db70b83 commit bb8f91e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/KV/KVClient.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,22 @@ public function get($key, QueryOptions $queryOptions = null)
8686
* @type \DCarbone\PHPConsulAPI\Error|null error, if any
8787
* )
8888
*/
89-
public function valueList($prefix, QueryOptions $queryOptions = null)
89+
public function valueList($prefix = '', QueryOptions $queryOptions = null)
9090
{
91-
if (!is_string($prefix) || '' === $prefix)
91+
if (!is_string($prefix))
9292
{
9393
return [null, null, new Error(sprintf(
94-
'%s::valueList - Prefix expected to be non-empty string, "%s" seen.',
94+
'%s::valueList - Prefix expected to be string, "%s" seen.',
9595
get_class($this),
96-
is_string($prefix) ? $prefix : gettype($prefix)
96+
gettype($prefix)
9797
))];
9898
}
9999

100-
$r = new HttpRequest('get', sprintf('v1/kv/%s', $prefix), $this->_Config);
100+
if ('' === $prefix)
101+
$r = new HttpRequest('get', 'v1/kv', $this->_Config);
102+
else
103+
$r = new HttpRequest('get', sprintf('v1/kv/%s', $prefix), $this->_Config);
104+
101105
$r->setQueryOptions($queryOptions);
102106
$r->params->set('recurse', '');
103107

@@ -276,7 +280,7 @@ public function release(KVPair $p, WriteOptions $writeOptions = null)
276280
* @type \DCarbone\PHPConsulAPI\Error|null error, if any
277281
* )
278282
*/
279-
public function tree($prefix, QueryOptions $queryOptions = null)
283+
public function tree($prefix = '', QueryOptions $queryOptions = null)
280284
{
281285
list($valueList, $_, $err) = $this->valueList($prefix, $queryOptions);
282286

0 commit comments

Comments
 (0)