Changeset View
Changeset View
Standalone View
Standalone View
src/repository/remote/ArcanistRepositoryRemoteQuery.php
<?php | <?php | ||||
abstract class ArcanistRepositoryRemoteQuery | abstract class ArcanistRepositoryRemoteQuery | ||||
extends ArcanistRepositoryQuery { | extends ArcanistRepositoryQuery { | ||||
private $names; | private $names; | ||||
final public function withNames(array $names) { | final public function withNames(array $names) { | ||||
$this->names = $names; | $this->names = $names; | ||||
return $this; | return $this; | ||||
} | } | ||||
final public function execute() { | final public function execute() { | ||||
$api = $this->getRepositoryAPI(); | |||||
$refs = $this->newRemoteRefs(); | $refs = $this->newRemoteRefs(); | ||||
foreach ($refs as $ref) { | |||||
$ref->setRepositoryAPI($api); | |||||
} | |||||
$names = $this->names; | $names = $this->names; | ||||
if ($names !== null) { | if ($names !== null) { | ||||
$names = array_fuse($names); | $names = array_fuse($names); | ||||
foreach ($refs as $key => $ref) { | foreach ($refs as $key => $ref) { | ||||
if (!isset($names[$ref->getRemoteName()])) { | if (!isset($names[$ref->getRemoteName()])) { | ||||
unset($refs[$key]); | unset($refs[$key]); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return $refs; | return $refs; | ||||
} | } | ||||
abstract protected function newRemoteRefs(); | abstract protected function newRemoteRefs(); | ||||
} | } |