[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class ReleephBranchEditController extends ReleephBranchController { 4 5 private $branchID; 6 7 public function willProcessRequest(array $data) { 8 $this->branchID = $data['branchID']; 9 } 10 11 public function processRequest() { 12 $request = $this->getRequest(); 13 $viewer = $request->getUser(); 14 15 $branch = id(new ReleephBranchQuery()) 16 ->setViewer($viewer) 17 ->requireCapabilities( 18 array( 19 PhabricatorPolicyCapability::CAN_VIEW, 20 PhabricatorPolicyCapability::CAN_EDIT, 21 )) 22 ->withIDs(array($this->branchID)) 23 ->executeOne(); 24 if (!$branch) { 25 return new Aphront404Response(); 26 } 27 $this->setBranch($branch); 28 29 $symbolic_name = $request->getStr( 30 'symbolicName', 31 $branch->getSymbolicName()); 32 33 if ($request->isFormPost()) { 34 $existing_with_same_symbolic_name = 35 id(new ReleephBranch()) 36 ->loadOneWhere( 37 'id != %d AND releephProjectID = %d AND symbolicName = %s', 38 $branch->getID(), 39 $branch->getReleephProjectID(), 40 $symbolic_name); 41 42 $branch->openTransaction(); 43 $branch 44 ->setSymbolicName($symbolic_name); 45 46 if ($existing_with_same_symbolic_name) { 47 $existing_with_same_symbolic_name 48 ->setSymbolicName(null) 49 ->save(); 50 } 51 52 $branch->save(); 53 $branch->saveTransaction(); 54 55 return id(new AphrontRedirectResponse()) 56 ->setURI($this->getBranchViewURI($branch)); 57 } 58 59 $phids = array(); 60 61 $phids[] = $creator_phid = $branch->getCreatedByUserPHID(); 62 $phids[] = $cut_commit_phid = $branch->getCutPointCommitPHID(); 63 64 $handles = id(new PhabricatorHandleQuery()) 65 ->setViewer($request->getUser()) 66 ->withPHIDs($phids) 67 ->execute(); 68 69 $form = id(new AphrontFormView()) 70 ->setUser($request->getUser()) 71 ->appendChild( 72 id(new AphrontFormStaticControl()) 73 ->setLabel(pht('Branch Name')) 74 ->setValue($branch->getName())) 75 ->appendChild( 76 id(new AphrontFormMarkupControl()) 77 ->setLabel(pht('Cut Point')) 78 ->setValue($handles[$cut_commit_phid]->renderLink())) 79 ->appendChild( 80 id(new AphrontFormMarkupControl()) 81 ->setLabel(pht('Created By')) 82 ->setValue($handles[$creator_phid]->renderLink())) 83 ->appendChild( 84 id(new AphrontFormTextControl()) 85 ->setLabel(pht('Symbolic Name')) 86 ->setName('symbolicName') 87 ->setValue($symbolic_name) 88 ->setCaption(pht('Mutable alternate name, for easy reference, '. 89 '(e.g. "LATEST")'))) 90 ->appendChild( 91 id(new AphrontFormSubmitControl()) 92 ->addCancelButton($this->getBranchViewURI($branch)) 93 ->setValue(pht('Save Branch'))); 94 95 $title = pht( 96 'Edit Branch %s', 97 $branch->getDisplayNameWithDetail()); 98 99 $crumbs = $this->buildApplicationCrumbs(); 100 $crumbs->addTextCrumb(pht('Edit')); 101 102 $box = id(new PHUIObjectBoxView()) 103 ->setHeaderText($title) 104 ->appendChild($form); 105 106 return $this->buildApplicationPage( 107 array( 108 $crumbs, 109 $box, 110 ), 111 array( 112 'title' => $title, 113 )); 114 } 115 }
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 |