diff options
-rw-r--r-- | framework/TComponent.php | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/framework/TComponent.php b/framework/TComponent.php index 2fc0ebff..647653dd 100644 --- a/framework/TComponent.php +++ b/framework/TComponent.php @@ -608,8 +608,34 @@ class TComponent * @package System * @since 3.0 */ -class TEnumerable +class TEnumerable implements Iterator { + private $_enums = array(); + + public function __construct() { + $reflection = new ReflectionClass($this); + $this->_enums = $reflection->getConstants(); + } + + public function current() { + return current($this->_enums); + } + + public function key() { + return key($this->_enums); + } + + public function next() { + return next($this->_enums); + } + + public function rewind() { + reset($this->_enums); + } + + public function valid() { + return $this->current() !== false; + } } /** |