Changeset View
Changeset View
Standalone View
Standalone View
src/applications/doorkeeper/engine/DoorkeeperImportEngine.php
<?php | <?php | ||||
final class DoorkeeperImportEngine extends Phobject { | final class DoorkeeperImportEngine extends Phobject { | ||||
private $viewer; | private $viewer; | ||||
private $refs = array(); | private $refs = array(); | ||||
private $phids = array(); | private $phids = array(); | ||||
private $localOnly; | private $localOnly; | ||||
private $throwOnMissingLink; | private $throwOnMissingLink; | ||||
private $context = array(); | |||||
public function setViewer(PhabricatorUser $viewer) { | public function setViewer(PhabricatorUser $viewer) { | ||||
$this->viewer = $viewer; | $this->viewer = $viewer; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getViewer() { | public function getViewer() { | ||||
return $this->viewer; | return $this->viewer; | ||||
Show All 14 Lines | public function withPHIDs(array $phids) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function needLocalOnly($local_only) { | public function needLocalOnly($local_only) { | ||||
$this->localOnly = $local_only; | $this->localOnly = $local_only; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setContextProperty($key, $value) { | |||||
$this->context[$key] = $value; | |||||
return $this; | |||||
} | |||||
/** | /** | ||||
* Configure behavior if remote refs can not be retrieved because an | * Configure behavior if remote refs can not be retrieved because an | ||||
* authentication link is missing. | * authentication link is missing. | ||||
*/ | */ | ||||
public function setThrowOnMissingLink($throw) { | public function setThrowOnMissingLink($throw) { | ||||
$this->throwOnMissingLink = $throw; | $this->throwOnMissingLink = $throw; | ||||
return $this; | return $this; | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | if (!$this->localOnly) { | ||||
$bridges = id(new PhutilClassMapQuery()) | $bridges = id(new PhutilClassMapQuery()) | ||||
->setAncestorClass('DoorkeeperBridge') | ->setAncestorClass('DoorkeeperBridge') | ||||
->setFilterMethod('isEnabled') | ->setFilterMethod('isEnabled') | ||||
->execute(); | ->execute(); | ||||
foreach ($bridges as $key => $bridge) { | foreach ($bridges as $key => $bridge) { | ||||
$bridge->setViewer($viewer); | $bridge->setViewer($viewer); | ||||
$bridge->setThrowOnMissingLink($this->throwOnMissingLink); | $bridge->setThrowOnMissingLink($this->throwOnMissingLink); | ||||
$bridge->setContext($this->context); | |||||
} | } | ||||
$working_set = $refs; | $working_set = $refs; | ||||
foreach ($bridges as $bridge) { | foreach ($bridges as $bridge) { | ||||
$bridge_refs = array(); | $bridge_refs = array(); | ||||
foreach ($working_set as $key => $ref) { | foreach ($working_set as $key => $ref) { | ||||
if ($bridge->canPullRef($ref)) { | if ($bridge->canPullRef($ref)) { | ||||
$bridge_refs[$key] = $ref; | $bridge_refs[$key] = $ref; | ||||
Show All 17 Lines |