/** * 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; }
/** * 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; }
/** * @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(); }
/** * Accessor for the last request issued to the API. For debugging purposes. * * @return string */ public function getLastRequest() { return $this->api->getRequest(); }
/** * @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(); }