Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / harbormaster / controller / HarbormasterPlanBehaviorController.php
blob8f1fece6915a0cfcec8040327731bc6656a6d7f9
1 <?php
3 final class HarbormasterPlanBehaviorController
4 extends HarbormasterPlanController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
9 $plan = id(new HarbormasterBuildPlanQuery())
10 ->setViewer($viewer)
11 ->withIDs(array($request->getURIData('id')))
12 ->requireCapabilities(
13 array(
14 PhabricatorPolicyCapability::CAN_VIEW,
15 PhabricatorPolicyCapability::CAN_EDIT,
17 ->executeOne();
18 if (!$plan) {
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);
27 if (!$behavior) {
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');
37 $xactions = array();
39 $xactions[] = id(new HarbormasterBuildPlanTransaction())
40 ->setTransactionType(
41 HarbormasterBuildPlanBehaviorTransaction::TRANSACTIONTYPE)
42 ->setMetadataValue($metadata_key, $behavior_key)
43 ->setNewValue($v_option);
45 $editor = id(new HarbormasterBuildPlanEditor())
46 ->setActor($viewer)
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())
57 ->setName('option')
58 ->setValue($v_option)
59 ->setLabel(pht('Option'));
61 foreach ($behavior->getOptions() as $option) {
62 $icon = id(new PHUIIconView())
63 ->setIcon($option->getIcon());
65 $select_control->addButton(
66 $option->getKey(),
67 array(
68 $icon,
69 ' ',
70 $option->getName(),
72 $option->getDescription());
75 $form = id(new AphrontFormView())
76 ->setViewer($viewer)
77 ->appendInstructions(
78 pht(
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()))
86 ->appendForm($form)
87 ->setWidth(AphrontDialogView::WIDTH_FORM)
88 ->addSubmitButton(pht('Save Changes'))
89 ->addCancelButton($plan_uri);