[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class ReleephBranch extends ReleephDAO 4 implements PhabricatorPolicyInterface { 5 6 protected $releephProjectID; 7 protected $isActive; 8 protected $createdByUserPHID; 9 10 // The immutable name of this branch ('releases/foo-2013.01.24') 11 protected $name; 12 protected $basename; 13 14 // The symbolic name of this branch (LATEST, PRODUCTION, RC, ...) 15 // See SYMBOLIC_NAME_NOTE below 16 protected $symbolicName; 17 18 // Where to cut the branch 19 protected $cutPointCommitPHID; 20 21 protected $details = array(); 22 23 private $project = self::ATTACHABLE; 24 private $cutPointCommit = self::ATTACHABLE; 25 26 public function getConfiguration() { 27 return array( 28 self::CONFIG_AUX_PHID => true, 29 self::CONFIG_SERIALIZATION => array( 30 'details' => self::SERIALIZATION_JSON, 31 ), 32 self::CONFIG_COLUMN_SCHEMA => array( 33 'basename' => 'text64', 34 'isActive' => 'bool', 35 'symbolicName' => 'text64?', 36 'name' => 'text128', 37 ), 38 self::CONFIG_KEY_SCHEMA => array( 39 'releephProjectID' => array( 40 'columns' => array('releephProjectID', 'symbolicName'), 41 'unique' => true, 42 ), 43 'releephProjectID_2' => array( 44 'columns' => array('releephProjectID', 'basename'), 45 'unique' => true, 46 ), 47 'releephProjectID_name' => array( 48 'columns' => array('releephProjectID', 'name'), 49 'unique' => true, 50 ), 51 ), 52 ) + parent::getConfiguration(); 53 } 54 55 public function generatePHID() { 56 return PhabricatorPHID::generateNewPHID(ReleephBranchPHIDType::TYPECONST); 57 } 58 59 public function getDetail($key, $default = null) { 60 return idx($this->getDetails(), $key, $default); 61 } 62 63 public function setDetail($key, $value) { 64 $this->details[$key] = $value; 65 return $this; 66 } 67 68 public function willWriteData(array &$data) { 69 // If symbolicName is omitted, set it to the basename. 70 // 71 // This means that we can enforce symbolicName as a UNIQUE column in the 72 // DB. We'll interpret symbolicName === basename as meaning "no symbolic 73 // name". 74 // 75 // SYMBOLIC_NAME_NOTE 76 if (!$data['symbolicName']) { 77 $data['symbolicName'] = $data['basename']; 78 } 79 parent::willWriteData($data); 80 } 81 82 public function getSymbolicName() { 83 // See SYMBOLIC_NAME_NOTE above for why this is needed 84 if ($this->symbolicName == $this->getBasename()) { 85 return ''; 86 } 87 return $this->symbolicName; 88 } 89 90 public function setSymbolicName($name) { 91 if ($name) { 92 parent::setSymbolicName($name); 93 } else { 94 parent::setSymbolicName($this->getBasename()); 95 } 96 return $this; 97 } 98 99 public function getDisplayName() { 100 if ($sn = $this->getSymbolicName()) { 101 return $sn; 102 } 103 return $this->getBasename(); 104 } 105 106 public function getDisplayNameWithDetail() { 107 $n = $this->getBasename(); 108 if ($sn = $this->getSymbolicName()) { 109 return "{$sn} ({$n})"; 110 } else { 111 return $n; 112 } 113 } 114 115 public function getURI($path = null) { 116 $components = array( 117 '/releeph/branch', 118 $this->getID(), 119 $path, 120 ); 121 return implode('/', $components); 122 } 123 124 public function isActive() { 125 return $this->getIsActive(); 126 } 127 128 public function attachProject(ReleephProject $project) { 129 $this->project = $project; 130 return $this; 131 } 132 133 public function getProject() { 134 return $this->assertAttached($this->project); 135 } 136 137 public function getProduct() { 138 return $this->getProject(); 139 } 140 141 public function attachCutPointCommit( 142 PhabricatorRepositoryCommit $commit = null) { 143 $this->cutPointCommit = $commit; 144 return $this; 145 } 146 147 public function getCutPointCommit() { 148 return $this->assertAttached($this->cutPointCommit); 149 } 150 151 152 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 153 154 155 public function getCapabilities() { 156 return $this->getProduct()->getCapabilities(); 157 } 158 159 public function getPolicy($capability) { 160 return $this->getProduct()->getPolicy($capability); 161 } 162 163 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 164 return $this->getProduct()->hasAutomaticCapability($capability, $viewer); 165 } 166 167 public function describeAutomaticCapability($capability) { 168 return pht( 169 'Release branches have the same policies as the product they are a '. 170 'part of.'); 171 } 172 173 174 }
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 |