Changeset View
Changeset View
Standalone View
Standalone View
src/ref/ArcanistRefQuery.php
<?php | <?php | ||||
final class ArcanistRefQuery extends Phobject { | final class ArcanistRefQuery extends Phobject { | ||||
private $repositoryAPI; | private $repositoryAPI; | ||||
private $conduitEngine; | private $conduitEngine; | ||||
private $repositoryRef; | |||||
private $workingCopyRef; | |||||
private $refs; | private $refs; | ||||
private $hardpoints; | private $hardpoints; | ||||
private $loaders; | |||||
public function setRefs(array $refs) { | public function setRefs(array $refs) { | ||||
assert_instances_of($refs, 'ArcanistRef'); | assert_instances_of($refs, 'ArcanistRef'); | ||||
$this->refs = $refs; | $this->refs = $refs; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getRefs() { | public function getRefs() { | ||||
return $this->refs; | return $this->refs; | ||||
} | } | ||||
public function setRepositoryAPI(ArcanistRepositoryAPI $repository_api) { | public function setRepositoryAPI(ArcanistRepositoryAPI $repository_api) { | ||||
$this->repositoryAPI = $repository_api; | $this->repositoryAPI = $repository_api; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getRepositoryAPI() { | public function getRepositoryAPI() { | ||||
return $this->repositoryAPI; | return $this->repositoryAPI; | ||||
} | } | ||||
public function setRepositoryRef(ArcanistRepositoryRef $repository_ref) { | |||||
$this->repositoryRef = $repository_ref; | |||||
return $this; | |||||
} | |||||
public function getRepositoryRef() { | |||||
return $this->repositoryRef; | |||||
} | |||||
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 setWorkingCopyRef(ArcanistWorkingCopyStateRef $working_ref) { | |||||
$this->workingCopyRef = $working_ref; | |||||
return $this; | |||||
} | |||||
public function getWorkingCopyRef() { | |||||
return $this->workingCopyRef; | |||||
} | |||||
public function needHardpoints(array $hardpoints) { | public function needHardpoints(array $hardpoints) { | ||||
$this->hardpoints = $hardpoints; | $this->hardpoints = $hardpoints; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setLoaders(array $loaders) { | |||||
assert_instances_of($loaders, 'ArcanistHardpointLoader'); | |||||
foreach ($loaders as $key => $loader) { | |||||
$loader->setQuery($this); | |||||
} | |||||
$this->loaders = $loaders; | |||||
return $this; | |||||
} | |||||
public function execute() { | public function execute() { | ||||
$refs = $this->getRefs(); | $refs = $this->getRefs(); | ||||
if ($this->refs === null) { | if ($this->refs === null) { | ||||
throw new PhutilInvalidStateException('setRefs'); | throw new PhutilInvalidStateException('setRefs'); | ||||
} | } | ||||
if ($this->hardpoints === null) { | if ($this->hardpoints === null) { | ||||
throw new PhutilInvalidStateException('needHardpoints'); | throw new PhutilInvalidStateException('needHardpoints'); | ||||
} | } | ||||
$api = $this->getRepositoryAPI(); | if ($this->loaders == null) { | ||||
$all_loaders = ArcanistHardpointLoader::getAllLoaders(); | $all_loaders = ArcanistHardpointLoader::getAllLoaders(); | ||||
foreach ($all_loaders as $key => $loader) { | |||||
$all_loaders[$key] = clone $loader; | |||||
} | |||||
$this->setLoaders($all_loaders); | |||||
} | |||||
$all_loaders = $this->loaders; | |||||
$api = $this->getRepositoryAPI(); | |||||
$loaders = array(); | $loaders = array(); | ||||
foreach ($all_loaders as $loader_key => $loader) { | foreach ($all_loaders as $loader_key => $loader) { | ||||
if ($api) { | |||||
if (!$loader->canLoadRepositoryAPI($api)) { | if (!$loader->canLoadRepositoryAPI($api)) { | ||||
continue; | continue; | ||||
} | } | ||||
} | |||||
$loaders[$loader_key] = id(clone $loader) | $loaders[$loader_key] = id(clone $loader) | ||||
->setQuery($this); | ->setQuery($this); | ||||
} | } | ||||
foreach ($this->hardpoints as $hardpoint) { | foreach ($this->hardpoints as $hardpoint) { | ||||
$load = array(); | $load = array(); | ||||
$need = array(); | $need = array(); | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |