Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/chart/PhabricatorChartFunction.php
<?php | <?php | ||||
abstract class PhabricatorChartFunction | abstract class PhabricatorChartFunction | ||||
extends Phobject { | extends Phobject { | ||||
private $xAxis; | private $xAxis; | ||||
private $yAxis; | private $yAxis; | ||||
private $limit; | private $limit; | ||||
private $argumentParser; | |||||
final public function getFunctionKey() { | final public function getFunctionKey() { | ||||
return $this->getPhobjectClassConstant('FUNCTIONKEY', 32); | return $this->getPhobjectClassConstant('FUNCTIONKEY', 32); | ||||
} | } | ||||
final public static function getAllFunctions() { | final public static function getAllFunctions() { | ||||
return id(new PhutilClassMapQuery()) | return id(new PhutilClassMapQuery()) | ||||
->setAncestorClass(__CLASS__) | ->setAncestorClass(__CLASS__) | ||||
->setUniqueMethod('getFunctionKey') | ->setUniqueMethod('getFunctionKey') | ||||
->execute(); | ->execute(); | ||||
} | } | ||||
final public function setArguments(array $arguments) { | final public function setArguments(array $arguments) { | ||||
$this->newArguments($arguments); | $parser = $this->getArgumentParser(); | ||||
$parser->setRawArguments($arguments); | |||||
$specs = $this->newArguments(); | |||||
if (!is_array($specs)) { | |||||
throw new Exception( | |||||
pht( | |||||
'Expected "newArguments()" in class "%s" to return a list of '. | |||||
'argument specifications, got %s.', | |||||
get_class($this), | |||||
phutil_describe_type($specs))); | |||||
} | |||||
assert_instances_of($specs, 'PhabricatorChartFunctionArgument'); | |||||
foreach ($specs as $spec) { | |||||
$parser->addArgument($spec); | |||||
} | |||||
$parser->setHaveAllArguments(true); | |||||
$parser->parseArguments(); | |||||
return $this; | return $this; | ||||
} | } | ||||
abstract protected function newArguments(array $arguments); | abstract protected function newArguments(); | ||||
final protected function newArgument() { | |||||
return new PhabricatorChartFunctionArgument(); | |||||
} | |||||
final protected function getArgument($key) { | |||||
return $this->getArgumentParser()->getArgumentValue($key); | |||||
} | |||||
final protected function getArgumentParser() { | |||||
if (!$this->argumentParser) { | |||||
$parser = id(new PhabricatorChartFunctionArgumentParser()) | |||||
->setFunction($this); | |||||
$this->argumentParser = $parser; | |||||
} | |||||
return $this->argumentParser; | |||||
} | |||||
public function loadData() { | public function loadData() { | ||||
return; | return; | ||||
} | } | ||||
final public function setXAxis(PhabricatorChartAxis $x_axis) { | final public function setXAxis(PhabricatorChartAxis $x_axis) { | ||||
$this->xAxis = $x_axis; | $this->xAxis = $x_axis; | ||||
return $this; | return $this; | ||||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |