[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class HarbormasterStepAddController 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(new HarbormasterBuildPlanQuery()) 19 ->setViewer($viewer) 20 ->withIDs(array($this->id)) 21 ->executeOne(); 22 if (!$plan) { 23 return new Aphront404Response(); 24 } 25 26 $plan_id = $plan->getID(); 27 $cancel_uri = $this->getApplicationURI("plan/{$plan_id}/"); 28 29 $errors = array(); 30 if ($request->isFormPost()) { 31 $class = $request->getStr('class'); 32 if (!HarbormasterBuildStepImplementation::getImplementation($class)) { 33 $errors[] = pht('Choose the type of build step you want to add.'); 34 } 35 if (!$errors) { 36 $new_uri = $this->getApplicationURI("step/new/{$plan_id}/{$class}/"); 37 return id(new AphrontRedirectResponse())->setURI($new_uri); 38 } 39 } 40 41 $control = id(new AphrontFormRadioButtonControl()) 42 ->setName('class'); 43 44 $all = HarbormasterBuildStepImplementation::getImplementations(); 45 foreach ($all as $class => $implementation) { 46 $control->addButton( 47 $class, 48 $implementation->getName(), 49 $implementation->getGenericDescription()); 50 } 51 52 if ($errors) { 53 $errors = id(new AphrontErrorView()) 54 ->setErrors($errors); 55 } 56 57 return $this->newDialog() 58 ->setTitle(pht('Add New Step')) 59 ->addSubmitButton(pht('Add Build Step')) 60 ->addCancelButton($cancel_uri) 61 ->appendChild($errors) 62 ->appendParagraph(pht('Choose a type of build step to add:')) 63 ->appendChild($control); 64 } 65 66 }
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 |