Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/storage/PhabricatorFactChart.php
- This file was added.
<?php | |||||
final class PhabricatorFactChart | |||||
extends PhabricatorFactDAO | |||||
implements PhabricatorPolicyInterface { | |||||
protected $chartKey; | |||||
protected $chartParameters = array(); | |||||
protected function getConfiguration() { | |||||
return array( | |||||
self::CONFIG_SERIALIZATION => array( | |||||
'chartParameters' => self::SERIALIZATION_JSON, | |||||
), | |||||
self::CONFIG_COLUMN_SCHEMA => array( | |||||
'chartKey' => 'bytes12', | |||||
), | |||||
self::CONFIG_KEY_SCHEMA => array( | |||||
'key_chart' => array( | |||||
'columns' => array('chartKey'), | |||||
'unique' => true, | |||||
), | |||||
), | |||||
) + parent::getConfiguration(); | |||||
} | |||||
public function setChartParameter($key, $value) { | |||||
$this->chartParameters[$key] = $value; | |||||
return $this; | |||||
} | |||||
public function getChartParameter($key, $default = null) { | |||||
return idx($this->chartParameters, $key, $default); | |||||
} | |||||
public function save() { | |||||
if ($this->getID()) { | |||||
throw new Exception( | |||||
pht( | |||||
'Chart configurations are not mutable. You can not update or '. | |||||
'overwrite an existing chart configuration.')); | |||||
} | |||||
$digest = serialize($this->chartParameters); | |||||
$digest = PhabricatorHash::digestForIndex($digest); | |||||
$this->chartKey = $digest; | |||||
return parent::save(); | |||||
} | |||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | |||||
public function getCapabilities() { | |||||
return array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
amckinley: I can see the exception above, and this is consistent with charts being immutable, but is that… | |||||
epriestleyAuthorUnsubmitted Done Inline ActionsI think I'm currently planning to have some other object later which is analogous to a "NamedQuery", where you click a button like "[I like this chart]", pick a name, it saves to your list of charts you like, and you can update it later (but updating the chart part just points it at a different one of these immutable objects). The mutable object can have a name, can have its underlying actual chart updated, can be tagged with projects, etc. So if you have something you look at in your standup every morning or something, it'd get saved as a proper chart. Maybe? But maybe dashboard widgets are this object? So I guess I'm not totally sure yet. epriestley: I think I'm currently planning to have some other object later which is analogous to a… | |||||
); | |||||
} | |||||
public function getPolicy($capability) { | |||||
return PhabricatorPolicies::getMostOpenPolicy(); | |||||
} | |||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | |||||
return false; | |||||
} | |||||
} |
I can see the exception above, and this is consistent with charts being immutable, but is that the plan going forward? Or is this "if you want to edit the chart, fork it", ala saved queries?