[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * An individual dashboard panel. 5 */ 6 final class PhabricatorDashboardPanel 7 extends PhabricatorDashboardDAO 8 implements 9 PhabricatorPolicyInterface, 10 PhabricatorCustomFieldInterface, 11 PhabricatorDestructibleInterface { 12 13 protected $name; 14 protected $panelType; 15 protected $viewPolicy; 16 protected $editPolicy; 17 protected $isArchived = 0; 18 protected $properties = array(); 19 20 private $customFields = self::ATTACHABLE; 21 22 public static function initializeNewPanel(PhabricatorUser $actor) { 23 return id(new PhabricatorDashboardPanel()) 24 ->setName('') 25 ->setViewPolicy(PhabricatorPolicies::POLICY_USER) 26 ->setEditPolicy($actor->getPHID()); 27 } 28 29 public static function copyPanel( 30 PhabricatorDashboardPanel $dst, 31 PhabricatorDashboardPanel $src) { 32 33 $dst->name = $src->name; 34 $dst->panelType = $src->panelType; 35 $dst->properties = $src->properties; 36 37 return $dst; 38 } 39 40 public function getConfiguration() { 41 return array( 42 self::CONFIG_AUX_PHID => true, 43 self::CONFIG_SERIALIZATION => array( 44 'properties' => self::SERIALIZATION_JSON, 45 ), 46 self::CONFIG_COLUMN_SCHEMA => array( 47 'name' => 'text255', 48 'panelType' => 'text64', 49 'isArchived' => 'bool', 50 ), 51 ) + parent::getConfiguration(); 52 } 53 54 public function generatePHID() { 55 return PhabricatorPHID::generateNewPHID( 56 PhabricatorDashboardPanelPHIDType::TYPECONST); 57 } 58 59 public function getProperty($key, $default = null) { 60 return idx($this->properties, $key, $default); 61 } 62 63 public function setProperty($key, $value) { 64 $this->properties[$key] = $value; 65 return $this; 66 } 67 68 public function getMonogram() { 69 return 'W'.$this->getID(); 70 } 71 72 public function getImplementation() { 73 return idx( 74 PhabricatorDashboardPanelType::getAllPanelTypes(), 75 $this->getPanelType()); 76 } 77 78 public function requireImplementation() { 79 $impl = $this->getImplementation(); 80 if (!$impl) { 81 throw new Exception( 82 pht( 83 'Attempting to use a panel in a way that requires an '. 84 'implementation, but the panel implementation ("%s") is unknown to '. 85 'Phabricator.', 86 $this->getPanelType())); 87 } 88 return $impl; 89 } 90 91 92 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 93 94 95 public function getCapabilities() { 96 return array( 97 PhabricatorPolicyCapability::CAN_VIEW, 98 PhabricatorPolicyCapability::CAN_EDIT, 99 ); 100 } 101 102 public function getPolicy($capability) { 103 switch ($capability) { 104 case PhabricatorPolicyCapability::CAN_VIEW: 105 return $this->getViewPolicy(); 106 case PhabricatorPolicyCapability::CAN_EDIT: 107 return $this->getEditPolicy(); 108 } 109 } 110 111 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 112 return false; 113 } 114 115 public function describeAutomaticCapability($capability) { 116 return null; 117 } 118 119 120 /* -( PhabricatorCustomFieldInterface )------------------------------------ */ 121 122 123 public function getCustomFieldSpecificationForRole($role) { 124 return array(); 125 } 126 127 public function getCustomFieldBaseClass() { 128 return 'PhabricatorDashboardPanelCustomField'; 129 } 130 131 public function getCustomFields() { 132 return $this->assertAttached($this->customFields); 133 } 134 135 public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) { 136 $this->customFields = $fields; 137 return $this; 138 } 139 140 141 /* -( PhabricatorDestructibleInterface )----------------------------------- */ 142 143 144 public function destroyObjectPermanently( 145 PhabricatorDestructionEngine $engine) { 146 147 $this->openTransaction(); 148 $this->delete(); 149 $this->saveTransaction(); 150 } 151 152 }
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 |