[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class ReleephBranchSearchEngine 4 extends PhabricatorApplicationSearchEngine { 5 6 private $product; 7 8 public function getResultTypeDescription() { 9 return pht('Releeph Branches'); 10 } 11 12 public function setProduct(ReleephProject $product) { 13 $this->product = $product; 14 return $this; 15 } 16 17 public function getProduct() { 18 return $this->product; 19 } 20 21 public function buildSavedQueryFromRequest(AphrontRequest $request) { 22 $saved = new PhabricatorSavedQuery(); 23 24 $saved->setParameter('active', $request->getStr('active')); 25 26 return $saved; 27 } 28 29 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 30 $query = id(new ReleephBranchQuery()) 31 ->needCutPointCommits(true) 32 ->withProductPHIDs(array($this->getProduct()->getPHID())); 33 34 $active = $saved->getParameter('active'); 35 $value = idx($this->getActiveValues(), $active); 36 if ($value !== null) { 37 $query->withStatus($value); 38 } 39 40 return $query; 41 } 42 43 public function buildSearchForm( 44 AphrontFormView $form, 45 PhabricatorSavedQuery $saved_query) { 46 47 $form->appendChild( 48 id(new AphrontFormSelectControl()) 49 ->setName('active') 50 ->setLabel(pht('Show Branches')) 51 ->setValue($saved_query->getParameter('active')) 52 ->setOptions($this->getActiveOptions())); 53 } 54 55 protected function getURI($path) { 56 return '/releeph/product/'.$this->getProduct()->getID().'/'.$path; 57 } 58 59 public function getBuiltinQueryNames() { 60 $names = array( 61 'open' => pht('Open'), 62 'all' => pht('All'), 63 ); 64 65 return $names; 66 } 67 68 public function buildSavedQueryFromBuiltin($query_key) { 69 70 $query = $this->newSavedQuery(); 71 $query->setQueryKey($query_key); 72 73 switch ($query_key) { 74 case 'open': 75 return $query 76 ->setParameter('active', 'open'); 77 case 'all': 78 return $query; 79 } 80 81 return parent::buildSavedQueryFromBuiltin($query_key); 82 } 83 84 private function getActiveOptions() { 85 return array( 86 'open' => pht('Open Branches'), 87 'all' => pht('Open and Closed Branches'), 88 ); 89 } 90 91 private function getActiveValues() { 92 return array( 93 'open' => ReleephBranchQuery::STATUS_OPEN, 94 'all' => ReleephBranchQuery::STATUS_ALL, 95 ); 96 } 97 98 }
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 |