Changeset View
Changeset View
Standalone View
Standalone View
src/toolset/ArcanistPrompt.php
<?php | <?php | ||||
final class ArcanistPrompt | final class ArcanistPrompt | ||||
extends Phobject { | extends Phobject { | ||||
private $key; | private $key; | ||||
private $workflow; | private $workflow; | ||||
private $description; | private $description; | ||||
private $query; | private $query; | ||||
private $abortsWorkflow; | |||||
public function setKey($key) { | public function setKey($key) { | ||||
$this->key = $key; | $this->key = $key; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getKey() { | public function getKey() { | ||||
return $this->key; | return $this->key; | ||||
Show All 21 Lines | public function setQuery($query) { | ||||
$this->query = $query; | $this->query = $query; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getQuery() { | public function getQuery() { | ||||
return $this->query; | return $this->query; | ||||
} | } | ||||
public function setAbortsWorkflow($aborts_workflow) { | |||||
$this->abortsWorkflow = $aborts_workflow; | |||||
return $this; | |||||
} | |||||
public function getAbortsWorkflow() { | |||||
return $this->abortsWorkflow; | |||||
} | |||||
public function execute() { | public function execute() { | ||||
$workflow = $this->getWorkflow(); | $workflow = $this->getWorkflow(); | ||||
if ($workflow) { | if ($workflow) { | ||||
$workflow_ok = $workflow->hasPrompt($this->getKey()); | $workflow_ok = $workflow->hasPrompt($this->getKey()); | ||||
} else { | } else { | ||||
$workflow_ok = false; | $workflow_ok = false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | if ($is_saved) { | ||||
$query, | $query, | ||||
$response, | $response, | ||||
'>>>', | '>>>', | ||||
pht( | pht( | ||||
'Using saved response to prompt "%s".', | 'Using saved response to prompt "%s".', | ||||
$this->getKey())); | $this->getKey())); | ||||
} | } | ||||
if (!$result) { | $allow_abort = $this->abortsWorkflow === null || $this->abortsWorkflow; | ||||
if ($allow_abort && !$result) { | |||||
throw new ArcanistUserAbortException(); | throw new ArcanistUserAbortException(); | ||||
} | } | ||||
return $result; | |||||
} | } | ||||
private function getSavedResponse() { | private function getSavedResponse() { | ||||
$config_key = ArcanistArcConfigurationEngineExtension::KEY_PROMPTS; | $config_key = ArcanistArcConfigurationEngineExtension::KEY_PROMPTS; | ||||
$workflow = $this->getWorkflow(); | $workflow = $this->getWorkflow(); | ||||
$config = $workflow->getConfig($config_key); | $config = $workflow->getConfig($config_key); | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |