Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Basho\Riak\Command\Builder; | ||
|
||
use Basho\Riak; | ||
use Basho\Riak\Command; | ||
|
||
/** | ||
* Used to list KV objects in Riak | ||
* | ||
* <code> | ||
* $command = (new Command\Builder\ListObjecst($riak)) | ||
* ->buildBucket('users', 'default') | ||
* ->build(); | ||
* | ||
* $response = $command->execute(); | ||
* | ||
* $key = $response->getObject(); | ||
* </code> | ||
* | ||
* @author Christopher Mancini <cmancini at basho d0t com> | ||
*/ | ||
class ListObjects extends Command\Builder implements Command\BuilderInterface | ||
{ | ||
use BucketTrait; | ||
use ObjectTrait; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
protected $decodeAsAssociative = false; | ||
|
||
public function __construct(Riak $riak) | ||
{ | ||
parent::__construct($riak); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return Command\Object\Keys | ||
*/ | ||
public function build() | ||
{ | ||
$this->validate(); | ||
|
||
return new Command\Object\Keys($this); | ||
} | ||
|
||
/** | ||
* Tells the client to decode the data as an associative array instead of a PHP stdClass object. | ||
* Only works if the fetched object type is JSON. | ||
* | ||
* @return $this | ||
*/ | ||
public function withDecodeAsAssociative() | ||
{ | ||
$this->decodeAsAssociative = true; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Fetch the setting for decodeAsAssociative. | ||
* | ||
* @return bool | ||
*/ | ||
public function getDecodeAsAssociative() | ||
{ | ||
return $this->decodeAsAssociative; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function validate() | ||
{ | ||
$this->required('Bucket'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Basho\Riak\Command\Object; | ||
|
||
use Basho\Riak\Command; | ||
use Basho\Riak\CommandInterface; | ||
|
||
/** | ||
* Lists Riak Kv Object keys | ||
* | ||
* @author Christopher Mancini <cmancini at basho d0t com> | ||
*/ | ||
class Keys extends Command\Object implements CommandInterface | ||
{ | ||
public function __construct(Command\Builder\ListObjects $builder) | ||
{ | ||
parent::__construct($builder); | ||
|
||
$this->parameters['keys'] = 'true'; | ||
$this->bucket = $builder->getBucket(); | ||
$this->decodeAsAssociative = $builder->getDecodeAsAssociative(); | ||
} | ||
} |