From d6bae028524a0fc548080d7b8ae1d8fa38102248 Mon Sep 17 00:00:00 2001 From: Kore Nordmann Date: Tue, 27 Jun 2006 09:18:13 +0000 Subject: - Applied API change for accessing datasets to be able to distinguish easier between chart elements and datasets # Changes the way datasets are accessed for charts # Old: # $chart->dataset = array( ... ); # New: # $chart['dataset'] = array( ... ); --- src/exceptions/no_such_element.php | 25 +++++++++++++++++++++++ src/graph_autoload.php | 1 + src/interfaces/chart.php | 41 ++++++++++++++++++++++++++++++-------- 3 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 src/exceptions/no_such_element.php (limited to 'src') diff --git a/src/exceptions/no_such_element.php b/src/exceptions/no_such_element.php new file mode 100644 index 0000000..6832d23 --- /dev/null +++ b/src/exceptions/no_such_element.php @@ -0,0 +1,25 @@ + found." ); + } +} + +?> diff --git a/src/graph_autoload.php b/src/graph_autoload.php index ef0aecf..912f18a 100644 --- a/src/graph_autoload.php +++ b/src/graph_autoload.php @@ -46,6 +46,7 @@ return array( 'ezcGraphUnknownPaletteException' => 'Graph/exceptions/unknown_palette.php', 'ezcGraphChartElement' => 'Graph/interfaces/element.php', + 'ezcGraphNoSuchElementException' => 'Graph/exceptions/no_such_element.php', 'ezcGraphFontOptions' => 'Graph/options/font.php', 'ezcGraphChartElementText' => 'Graph/element/text.php', 'ezcGraphChartElementLegend' => 'Graph/element/legend.php', diff --git a/src/interfaces/chart.php b/src/interfaces/chart.php index de990bd..6cc1e8c 100644 --- a/src/interfaces/chart.php +++ b/src/interfaces/chart.php @@ -12,7 +12,7 @@ * * @package Graph */ -abstract class ezcGraphChart +abstract class ezcGraphChart implements ArrayAccess { /** @@ -161,7 +161,7 @@ abstract class ezcGraphChart throw new ezcBaseValueException( "options", $propertyValue, "instanceof ezcGraphOptions" ); } default: - return $this->addDataSet($propertyName, $propertyValue); + throw new ezcBasePropertyNotFoundException( $propertyName ); break; } } @@ -235,19 +235,44 @@ abstract class ezcGraphChart return $this->elements[$propertyName]; } - if ( isset( $this->data[$propertyName] ) ) - { - return $this->data[$propertyName]; - } - if ( $propertyName === "options" ) { return $this->options; } else { - throw new ezcGraphNoSuchDatasetException( $propertyName ); + throw new ezcGraphNoSuchElementException( $propertyName ); + } + } + + public function offsetExists( $key ) + { + return isset( $this->data[$key] ); + } + + public function offsetGet( $key ) + { + if ( !isset( $key ) ) + { + throw new ezcGraphNoSuchDatasetException( $key ); } + + return $this->data[$key]; + } + + public function offsetSet( $key, $value ) + { + return $this->addDataset( $key, $value ); + } + + public function offsetUnset( $key ) + { + if ( !isset( $key ) ) + { + throw new ezcGraphNoSuchDatasetException( $key ); + } + + unset( $this->data[$key] ); } public function setOptions( $options ) -- cgit v1.1