diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-06-27 09:18:13 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-06-27 09:18:13 +0000 |
commit | d6bae028524a0fc548080d7b8ae1d8fa38102248 (patch) | |
tree | df0afe090b02444f05cc092aa53cd9b433e22c49 /src | |
parent | 50e3d65302d7515cee6b2a677d16bc59d4cf4c8a (diff) | |
download | zetacomponents-graph-d6bae028524a0fc548080d7b8ae1d8fa38102248.zip zetacomponents-graph-d6bae028524a0fc548080d7b8ae1d8fa38102248.tar.gz |
- 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( ... );
Diffstat (limited to 'src')
-rw-r--r-- | src/exceptions/no_such_element.php | 25 | ||||
-rw-r--r-- | src/graph_autoload.php | 1 | ||||
-rw-r--r-- | src/interfaces/chart.php | 41 |
3 files changed, 59 insertions, 8 deletions
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 @@ +<?php +/** + * File containing the ezcGraphNoSuchElementException class + * + * @package Graph + * @version //autogen// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +/** + * ezcGraphUnknownChartTypeException is the exception which is thrown when the + * factory method tries to return an instance of an unknown chart type + * + * @package Graph + * @version //autogen// + */ +class ezcGraphNoSuchElementException extends ezcGraphException +{ + public function __construct( $name ) + { + parent::__construct( "No chart element with name <{$name}> 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 ) |