Ejemplo n.º 1
0
 /**
  * Prepare request to be sent
  *
  * @param Command $command
  * @param Node $node
  *
  * @return $this
  */
 public function prepare(Command $command, Node $node)
 {
     // call parent prepare method to setup object members
     parent::prepare($command, $node);
     if ($this->connection === null) {
         $this->openConnection();
     }
     // determine message code and build message content
     $this->prepareMessage();
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Prepare request to be sent
  *
  * @param Command $command
  * @param Node $node
  *
  * @return $this
  */
 public function prepare(Command $command, Node $node)
 {
     if ($this->connection) {
         $this->resetConnection();
     }
     // call parent prepare method to setup object members
     parent::prepare($command, $node);
     // set the API path to be used
     $this->buildPath();
     // general connection preparation
     $this->prepareConnection();
     // request specific connection preparation
     $this->prepareRequest();
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * @param Command $command
  * @param Api $api
  *
  * @return Command\Response
  * @throws Exception
  */
 public function execute(Command $command, Api $api)
 {
     $success = $api->prepare($command, $this)->send();
     if ($success === FALSE) {
         return false;
     }
     return $api->getResponse();
 }
Ejemplo n.º 4
0
 /**
  * Accessor for the last request issued to the API. For debugging purposes.
  *
  * @return string
  */
 public function getLastRequest()
 {
     return $this->api->getRequest();
 }
Ejemplo n.º 5
0
 /**
  * @param Command $command
  * @param Api $api
  *
  * @return Command\Response
  * @throws Exception
  */
 public function execute(Command $command, Api $api)
 {
     $success = $api->prepare($command, $this)->send();
     if ($success === FALSE) {
         throw new Exception('Command failed to execute against Riak. Error Msg: ' . $api->getError());
     }
     $command->setResponse($api->getStatusCode(), $api->getResponseHeaders(), $api->getResponseBody());
     return $command->getResponse();
 }