Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistWorkflow.php
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | abstract class ArcanistWorkflow extends Phobject { | ||||
private $conduitEngine; | private $conduitEngine; | ||||
private $toolset; | private $toolset; | ||||
private $runtime; | private $runtime; | ||||
private $configurationEngine; | private $configurationEngine; | ||||
private $configurationSourceList; | private $configurationSourceList; | ||||
private $hardpointEngine; | private $hardpointEngine; | ||||
private $promptMap; | |||||
final public function setToolset(ArcanistToolset $toolset) { | final public function setToolset(ArcanistToolset $toolset) { | ||||
$this->toolset = $toolset; | $this->toolset = $toolset; | ||||
return $this; | return $this; | ||||
} | } | ||||
final public function getToolset() { | final public function getToolset() { | ||||
return $this->toolset; | return $this->toolset; | ||||
▲ Show 20 Lines • Show All 2,240 Lines • ▼ Show 20 Lines | foreach ($queries as $key => $query) { | ||||
->setWorkflow($this); | ->setWorkflow($this); | ||||
} | } | ||||
$engine->setQueries($queries); | $engine->setQueries($queries); | ||||
return $engine; | return $engine; | ||||
} | } | ||||
protected function newPrompts() { | |||||
return array(); | |||||
} | |||||
protected function newPrompt($key) { | |||||
return id(new ArcanistPrompt()) | |||||
->setWorkflow($this) | |||||
->setKey($key); | |||||
} | |||||
public function hasPrompt($key) { | |||||
$map = $this->getPromptMap(); | |||||
return isset($map[$key]); | |||||
} | |||||
public function getPromptMap() { | |||||
if ($this->promptMap === null) { | |||||
$prompts = $this->newPrompts(); | |||||
assert_instances_of($prompts, 'ArcanistPrompt'); | |||||
$map = array(); | |||||
foreach ($prompts as $prompt) { | |||||
$key = $prompt->getKey(); | |||||
if (isset($map[$key])) { | |||||
throw new Exception( | |||||
pht( | |||||
'Workflow ("%s") generates two prompts with the same '. | |||||
'key ("%s"). Each prompt a workflow generates must have a '. | |||||
'unique key.', | |||||
get_class($this), | |||||
$key)); | |||||
} | |||||
$map[$key] = $prompt; | |||||
} | |||||
$this->promptMap = $map; | |||||
} | |||||
return $this->promptMap; | |||||
} | |||||
protected function getPrompt($key) { | |||||
$map = $this->getPromptMap(); | |||||
$prompt = idx($map, $key); | |||||
if (!$prompt) { | |||||
throw new Exception( | |||||
pht( | |||||
'Workflow ("%s") is requesting a prompt ("%s") but it did not '. | |||||
'generate any prompt with that name in "newPrompts()".', | |||||
get_class($this), | |||||
$key)); | |||||
} | |||||
return clone $prompt; | |||||
} | |||||
} | } |