Differential D8599 Diff 20429 src/applications/harbormaster/controller/HarbormasterPlanOrderController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/controller/HarbormasterPlanOrderController.php
<?php | <?php | ||||
/** | |||||
* @group search | |||||
*/ | |||||
final class HarbormasterPlanOrderController extends HarbormasterController { | final class HarbormasterPlanOrderController extends HarbormasterController { | ||||
private $id; | private $id; | ||||
public function willProcessRequest(array $data) { | public function willProcessRequest(array $data) { | ||||
$this->id = idx($data, 'id'); | $this->id = idx($data, 'id'); | ||||
} | } | ||||
Show All 27 Lines | public function processRequest() { | ||||
$sequence = 1; | $sequence = 1; | ||||
foreach ($steps as $step) { | foreach ($steps as $step) { | ||||
$step->setSequence($sequence++); | $step->setSequence($sequence++); | ||||
$step->save(); | $step->save(); | ||||
$reordered_steps[] = $step; | $reordered_steps[] = $step; | ||||
} | } | ||||
// We must ensure that steps with artifacts become invalid if they are | // NOTE: Reordering steps may invalidate artifacts. This is fine; the UI | ||||
// placed before the steps that produce them. | // will show that there are ordering issues. | ||||
foreach ($reordered_steps as $step) { | |||||
$implementation = $step->getStepImplementation(); | |||||
$settings = $implementation->getSettings(); | |||||
foreach ($implementation->getSettingDefinitions() as $name => $opt) { | |||||
switch ($opt['type']) { | |||||
case BuildStepImplementation::SETTING_TYPE_ARTIFACT: | |||||
$value = $settings[$name]; | |||||
$filter = $opt['artifact_type']; | |||||
$available_artifacts = | |||||
BuildStepImplementation::getAvailableArtifacts( | |||||
$plan, | |||||
$reordered_steps, | |||||
$step, | |||||
$filter); | |||||
$artifact_found = false; | |||||
foreach ($available_artifacts as $key => $type) { | |||||
if ($key === $value) { | |||||
$artifact_found = true; | |||||
} | |||||
} | |||||
if (!$artifact_found) { | |||||
$step->setDetail($name, null); | |||||
} | |||||
break; | |||||
} | |||||
$step->save(); | |||||
} | |||||
} | |||||
// Force the page to re-render. | // Force the page to re-render. | ||||
return id(new AphrontRedirectResponse()); | return id(new AphrontRedirectResponse()); | ||||
} | } | ||||
} | } |