/** *This is all horribly terible and will be ripped out as soon as possible. * * Basically, This class stores an intermediate Command that maintains state across * chained requests, which allows updates (scripts, params, etc) to affect it. * * The command is finalized when a new document is added, or the request is executed. * Finalization means collapsing the doc field data into a param, as well as updating * the action/suffix as necessary. */ private function finalizeCurrentCommand() { if ($this->batch instanceof BatchCommand && $this->currentCommand !== null) { if (isset($this->params['update']) && $this->params['update'] === true) { $this->currentCommand->action('post')->suffix('_update'); if ($this->params['doc'] !== null) { $data["doc"] = $this->params['doc']; } if ($this->params['updateScript'] !== null) { $data["script"] = $this->params['updateScript']; } if ($this->params['updateParams'] !== null) { $data["params"] = $this->params['updateParams']; } if ($this->params['updateUpsert'] !== null) { $data["upsert"] = $this->params['updateUpsert']; } $this->currentCommand->data($data); } else { $this->currentCommand->data($this->params['doc']); } $this->batch->addCommand($this->currentCommand); $this->params['update'] = false; } $this->currentCommand = new Command(); }
/** * Execute the RawRequest * * @throws \Sherlock\common\exceptions\RuntimeException * @return \Sherlock\responses\QueryResponse */ public function execute() { if (!isset($this->params['uri'])) { throw new exceptions\RuntimeException("URI is required for RawRequest"); } if (!isset($this->params['method'])) { throw new exceptions\RuntimeException("Method is required for RawRequest"); } $command = new Command(); $command->index($this->params['uri'])->action($this->params['method']); if (isset($this->params['body'])) { $command->data($this->params['body']); } $this->batch->clearCommands(); $this->batch->addCommand($command); $ret = parent::execute(); return $ret[0]; }