@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at upstream/main 94 lines 2.3 kB view raw
1<?php 2 3final class PhabricatorFactChart 4 extends PhabricatorFactDAO 5 implements PhabricatorPolicyInterface { 6 7 protected $chartKey; 8 protected $chartParameters = array(); 9 10 private $datasets = self::ATTACHABLE; 11 12 protected function getConfiguration() { 13 return array( 14 self::CONFIG_SERIALIZATION => array( 15 'chartParameters' => self::SERIALIZATION_JSON, 16 ), 17 self::CONFIG_COLUMN_SCHEMA => array( 18 'chartKey' => 'bytes12', 19 ), 20 self::CONFIG_KEY_SCHEMA => array( 21 'key_chart' => array( 22 'columns' => array('chartKey'), 23 'unique' => true, 24 ), 25 ), 26 ) + parent::getConfiguration(); 27 } 28 29 public function setChartParameter($key, $value) { 30 $this->chartParameters[$key] = $value; 31 return $this; 32 } 33 34 public function getChartParameter($key, $default = null) { 35 return idx($this->chartParameters, $key, $default); 36 } 37 38 /** 39 * @return string 12-character string identifier of chart 40 */ 41 public function newChartKey() { 42 $digest = serialize($this->chartParameters); 43 $digest = PhabricatorHash::digestForIndex($digest); 44 return $digest; 45 } 46 47 public function save() { 48 if ($this->getID()) { 49 throw new Exception( 50 pht( 51 'Chart configurations are not mutable. You can not update or '. 52 'overwrite an existing chart configuration.')); 53 } 54 55 $this->chartKey = $this->newChartKey(); 56 57 return parent::save(); 58 } 59 60 /** 61 * @param array<PhabricatorChartDataset> $datasets 62 */ 63 public function attachDatasets(array $datasets) { 64 assert_instances_of($datasets, PhabricatorChartDataset::class); 65 $this->datasets = $datasets; 66 return $this; 67 } 68 69 public function getDatasets() { 70 return $this->assertAttached($this->datasets); 71 } 72 73 public function getURI() { 74 return urisprintf('/fact/chart/%s/', $this->getChartKey()); 75 } 76 77/* -( PhabricatorPolicyInterface )----------------------------------------- */ 78 79 public function getCapabilities() { 80 return array( 81 PhabricatorPolicyCapability::CAN_VIEW, 82 ); 83 } 84 85 public function getPolicy($capability) { 86 return PhabricatorPolicies::getMostOpenPolicy(); 87 } 88 89 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 90 return false; 91 } 92 93 94}