[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class HarbormasterPlanRunController extends HarbormasterController { 4 5 private $id; 6 7 public function willProcessRequest(array $data) { 8 $this->id = $data['id']; 9 } 10 11 public function processRequest() { 12 $request = $this->getRequest(); 13 $viewer = $request->getUser(); 14 15 $this->requireApplicationCapability( 16 HarbormasterManagePlansCapability::CAPABILITY); 17 18 $plan_id = $this->id; 19 $plan = id(new HarbormasterBuildPlanQuery()) 20 ->setViewer($viewer) 21 ->withIDs(array($plan_id)) 22 ->executeOne(); 23 if (!$plan) { 24 return new Aphront404Response(); 25 } 26 27 $e_name = true; 28 $v_name = null; 29 30 $errors = array(); 31 if ($request->isFormPost()) { 32 $buildable = HarbormasterBuildable::initializeNewBuildable($viewer) 33 ->setIsManualBuildable(true); 34 35 $v_name = $request->getStr('buildablePHID'); 36 37 if ($v_name) { 38 $object = id(new PhabricatorObjectQuery()) 39 ->setViewer($viewer) 40 ->withNames(array($v_name)) 41 ->executeOne(); 42 43 if ($object instanceof HarbormasterBuildableInterface) { 44 $buildable 45 ->setBuildablePHID($object->getHarbormasterBuildablePHID()) 46 ->setContainerPHID($object->getHarbormasterContainerPHID()); 47 } else { 48 $e_name = pht('Invalid'); 49 $errors[] = pht('Enter the name of a revision or commit.'); 50 } 51 } else { 52 $e_name = pht('Required'); 53 $errors[] = pht('You must choose a revision or commit to build.'); 54 } 55 56 if (!$errors) { 57 $buildable->save(); 58 $buildable->applyPlan($plan); 59 60 $buildable_uri = '/B'.$buildable->getID(); 61 return id(new AphrontRedirectResponse())->setURI($buildable_uri); 62 } 63 } 64 65 if ($errors) { 66 $errors = id(new AphrontErrorView())->setErrors($errors); 67 } 68 69 $title = pht('Run Build Plan Manually'); 70 $cancel_uri = $this->getApplicationURI("plan/{$plan_id}/"); 71 $save_button = pht('Run Plan Manually'); 72 73 $form = id(new PHUIFormLayoutView()) 74 ->setUser($viewer) 75 ->appendRemarkupInstructions( 76 pht( 77 "Enter the name of a commit or revision to run this plan on (for ". 78 "example, `rX123456` or `D123`).\n\n". 79 "For more detailed output, you can also run manual builds from ". 80 "the command line:\n\n". 81 " phabricator/ $ ./bin/harbormaster build <object> --plan %s", 82 $plan->getID())) 83 ->appendChild( 84 id(new AphrontFormTextControl()) 85 ->setLabel('Buildable Name') 86 ->setName('buildablePHID') 87 ->setError($e_name) 88 ->setValue($v_name)); 89 90 $dialog = id(new AphrontDialogView()) 91 ->setWidth(AphrontDialogView::WIDTH_FULL) 92 ->setUser($viewer) 93 ->setTitle($title) 94 ->appendChild($form) 95 ->addCancelButton($cancel_uri) 96 ->addSubmitButton($save_button); 97 98 return id(new AphrontDialogResponse())->setDialog($dialog); 99 } 100 101 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |