Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/chart/PhabricatorChartFunctionArgument.php
Show All 24 Lines | public function getRepeatable() { | ||||
return $this->repeatable; | return $this->repeatable; | ||||
} | } | ||||
public function setType($type) { | public function setType($type) { | ||||
$types = array( | $types = array( | ||||
'fact-key' => true, | 'fact-key' => true, | ||||
'function' => true, | 'function' => true, | ||||
'number' => true, | 'number' => true, | ||||
'phid' => true, | |||||
); | ); | ||||
if (!isset($types[$type])) { | if (!isset($types[$type])) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Chart function argument type "%s" is unknown. Valid types '. | 'Chart function argument type "%s" is unknown. Valid types '. | ||||
'are: %s.', | 'are: %s.', | ||||
$type, | $type, | ||||
implode(', ', array_keys($types)))); | implode(', ', array_keys($types)))); | ||||
} | } | ||||
$this->type = $type; | $this->type = $type; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getType() { | public function getType() { | ||||
return $this->type; | return $this->type; | ||||
} | } | ||||
public function newValue($value) { | public function newValue($value) { | ||||
switch ($this->getType()) { | switch ($this->getType()) { | ||||
case 'phid': | |||||
// TODO: This could be validated better, but probably should not be | |||||
// a primitive type. | |||||
epriestley: By this, I mean that the type should probably be "user" or "project" or whatever (not just… | |||||
return $value; | |||||
case 'fact-key': | case 'fact-key': | ||||
if (!is_string($value)) { | if (!is_string($value)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Value for "fact-key" argument must be a string, got %s.', | 'Value for "fact-key" argument must be a string, got %s.', | ||||
phutil_describe_type($value))); | phutil_describe_type($value))); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |
By this, I mean that the type should probably be "user" or "project" or whatever (not just "phid"), so we can accept @alice instead of PHID-USER-abcd. But I'm not yet sure how low-level the user-facing stuff is going to be.