3 final class HarbormasterPlanBehaviorController
4 extends HarbormasterPlanController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $this->getViewer();
9 $plan = id(new HarbormasterBuildPlanQuery())
11 ->withIDs(array($request->getURIData('id')))
12 ->requireCapabilities(
14 PhabricatorPolicyCapability
::CAN_VIEW
,
15 PhabricatorPolicyCapability
::CAN_EDIT
,
19 return new Aphront404Response();
22 $behavior_key = $request->getURIData('behaviorKey');
23 $metadata_key = HarbormasterBuildPlanBehavior
::getTransactionMetadataKey();
25 $behaviors = HarbormasterBuildPlanBehavior
::newPlanBehaviors();
26 $behavior = idx($behaviors, $behavior_key);
28 return new Aphront404Response();
31 $plan_uri = $plan->getURI();
33 $v_option = $behavior->getPlanOption($plan)->getKey();
34 if ($request->isFormPost()) {
35 $v_option = $request->getStr('option');
39 $xactions[] = id(new HarbormasterBuildPlanTransaction())
41 HarbormasterBuildPlanBehaviorTransaction
::TRANSACTIONTYPE
)
42 ->setMetadataValue($metadata_key, $behavior_key)
43 ->setNewValue($v_option);
45 $editor = id(new HarbormasterBuildPlanEditor())
47 ->setContinueOnNoEffect(true)
48 ->setContinueOnMissingFields(true)
49 ->setContentSourceFromRequest($request);
51 $editor->applyTransactions($plan, $xactions);
53 return id(new AphrontRedirectResponse())->setURI($plan_uri);
56 $select_control = id(new AphrontFormRadioButtonControl())
59 ->setLabel(pht('Option'));
61 foreach ($behavior->getOptions() as $option) {
62 $icon = id(new PHUIIconView())
63 ->setIcon($option->getIcon());
65 $select_control->addButton(
72 $option->getDescription());
75 $form = id(new AphrontFormView())
79 'Choose a build plan behavior for "%s".',
80 phutil_tag('strong', array(), $behavior->getName())))
81 ->appendRemarkupInstructions($behavior->getEditInstructions())
82 ->appendControl($select_control);
84 return $this->newDialog()
85 ->setTitle(pht('Edit Behavior: %s', $behavior->getName()))
87 ->setWidth(AphrontDialogView
::WIDTH_FORM
)
88 ->addSubmitButton(pht('Save Changes'))
89 ->addCancelButton($plan_uri);