mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 08:42:40 +01:00
Don't instantiate abstract classes in ArcanistConfiguration::buildAllWorkflows
Summary: I wanted to write a couple of workflows that shared some code in an abstract superclass, but ##arc## would fail trying to instantiate the abstract class. As it turns out, we can modernize the ##buildAllWorkflows## function a bit, and it will only load concrete objects. Test Plan: 1. Define an abstract subclass of ##ArcanistBaseWorkflow##. 2. ##arc liberate## the source directory that contains it. 3. Try any ##arc## operation without this diff, and see it fail. 4. Patch this diff and see that ##arc## operations work now. Reviewers: epriestley, vrana Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D6324
This commit is contained in:
parent
a746ad8757
commit
7130004015
1 changed files with 9 additions and 12 deletions
|
@ -33,28 +33,25 @@ class ArcanistConfiguration {
|
|||
}
|
||||
|
||||
public function buildAllWorkflows() {
|
||||
$symbols = id(new PhutilSymbolLoader())
|
||||
->setType('class')
|
||||
->setAncestorClass('ArcanistBaseWorkflow')
|
||||
->selectAndLoadSymbols();
|
||||
$workflows_by_name = array();
|
||||
|
||||
$workflows = array();
|
||||
foreach ($symbols as $symbol) {
|
||||
$class = $symbol['name'];
|
||||
$workflow = newv($class, array());
|
||||
$workflows_by_class_name = id(new PhutilSymbolLoader())
|
||||
->setAncestorClass('ArcanistBaseWorkflow')
|
||||
->loadObjects();
|
||||
foreach ($workflows_by_class_name as $class => $workflow) {
|
||||
$name = $workflow->getWorkflowName();
|
||||
|
||||
if (isset($workflows[$name])) {
|
||||
$other = get_class($workflows[$name]);
|
||||
if (isset($workflows_by_name[$name])) {
|
||||
$other = get_class($workflows_by_name[$name]);
|
||||
throw new Exception(
|
||||
"Workflows {$class} and {$other} both implement workflows named ".
|
||||
"{$name}.");
|
||||
}
|
||||
|
||||
$workflows[$workflow->getWorkflowName()] = $workflow;
|
||||
$workflows_by_name[$name] = $workflow;
|
||||
}
|
||||
|
||||
return $workflows;
|
||||
return $workflows_by_name;
|
||||
}
|
||||
|
||||
final public function isValidWorkflow($workflow) {
|
||||
|
|
Loading…
Reference in a new issue