Changeset View
Changeset View
Standalone View
Standalone View
src/conduit/ConduitSearchFuture.php
<?php | <?php | ||||
final class ConduitSearchFuture | final class ConduitSearchFuture | ||||
extends FutureAgent { | extends FutureAgent { | ||||
private $conduitEngine; | private $conduitEngine; | ||||
private $method; | private $method; | ||||
private $constraints; | private $constraints; | ||||
private $attachments; | |||||
private $objects = array(); | private $objects = array(); | ||||
private $cursor; | private $cursor; | ||||
public function setConduitEngine(ArcanistConduitEngine $conduit_engine) { | public function setConduitEngine(ArcanistConduitEngine $conduit_engine) { | ||||
$this->conduitEngine = $conduit_engine; | $this->conduitEngine = $conduit_engine; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getConduitEngine() { | public function getConduitEngine() { | ||||
return $this->conduitEngine; | return $this->conduitEngine; | ||||
} | } | ||||
public function setMethod($method) { | public function setMethod($method) { | ||||
$this->method = $method; | $this->method = $method; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getMethod() { | public function getMethod() { | ||||
return $this->method; | return $this->method; | ||||
} | } | ||||
public function setConstraints($constraints) { | public function setConstraints(array $constraints) { | ||||
$this->constraints = $constraints; | $this->constraints = $constraints; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getConstraints() { | public function getConstraints() { | ||||
return $this->constraints; | return $this->constraints; | ||||
} | } | ||||
public function setAttachments(array $attachments) { | |||||
$this->attachments = $attachments; | |||||
return $this; | |||||
} | |||||
public function getAttachments() { | |||||
return $this->attachments; | |||||
} | |||||
public function isReady() { | public function isReady() { | ||||
if ($this->hasResult()) { | if ($this->hasResult()) { | ||||
return true; | return true; | ||||
} | } | ||||
$futures = $this->getFutures(); | $futures = $this->getFutures(); | ||||
$future = head($futures); | $future = head($futures); | ||||
Show All 33 Lines | private function newFuture() { | ||||
$method = $this->getMethod(); | $method = $this->getMethod(); | ||||
$constraints = $this->getConstraints(); | $constraints = $this->getConstraints(); | ||||
$parameters = array( | $parameters = array( | ||||
'constraints' => $constraints, | 'constraints' => $constraints, | ||||
); | ); | ||||
if ($this->attachments) { | |||||
$parameters['attachments'] = $this->attachments; | |||||
} | |||||
if ($this->cursor !== null) { | if ($this->cursor !== null) { | ||||
$parameters['after'] = (string)$this->cursor; | $parameters['after'] = (string)$this->cursor; | ||||
} | } | ||||
$conduit_call = $engine->newCall($method, $parameters); | $conduit_call = $engine->newCall($method, $parameters); | ||||
$conduit_future = $engine->newFuture($conduit_call); | $conduit_future = $engine->newFuture($conduit_call); | ||||
return $conduit_future; | return $conduit_future; | ||||
} | } | ||||
private function readResults(array $data) { | private function readResults(array $data) { | ||||
return idx($data, 'data'); | return idx($data, 'data'); | ||||
} | } | ||||
} | } |