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(); | private $context = array(); | ||||
| private $timeout; | |||||
| 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 19 Lines | public function needLocalOnly($local_only) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setContextProperty($key, $value) { | public function setContextProperty($key, $value) { | ||||
| $this->context[$key] = $value; | $this->context[$key] = $value; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setTimeout($timeout) { | |||||
| $this->timeout = $timeout; | |||||
| return $this; | |||||
| } | |||||
| public function getTimeout() { | |||||
| return $this->timeout; | |||||
| } | |||||
| /** | /** | ||||
| * 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 All 39 Lines | public function execute() { | ||||
| } | } | ||||
| if (!$this->localOnly) { | if (!$this->localOnly) { | ||||
| $bridges = id(new PhutilClassMapQuery()) | $bridges = id(new PhutilClassMapQuery()) | ||||
| ->setAncestorClass('DoorkeeperBridge') | ->setAncestorClass('DoorkeeperBridge') | ||||
| ->setFilterMethod('isEnabled') | ->setFilterMethod('isEnabled') | ||||
| ->execute(); | ->execute(); | ||||
| $timeout = $this->getTimeout(); | |||||
| foreach ($bridges as $key => $bridge) { | foreach ($bridges as $key => $bridge) { | ||||
| $bridge->setViewer($viewer); | $bridge | ||||
| $bridge->setThrowOnMissingLink($this->throwOnMissingLink); | ->setViewer($viewer) | ||||
| $bridge->setContext($this->context); | ->setThrowOnMissingLink($this->throwOnMissingLink) | ||||
| ->setContext($this->context); | |||||
| if ($timeout !== null) { | |||||
| $bridge->setTimeout($timeout); | |||||
| } | |||||
| } | } | ||||
| $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 | |||||