From 88dc397e7c8bfdc3d76445191d553224a96606ed Mon Sep 17 00:00:00 2001 From: doctrine Date: Wed, 19 Apr 2006 20:03:23 +0000 Subject: [PATCH] --- classes/Doctrine.class.php | 1 + classes/Iterator.class.php | 30 --------------------------- classes/Iterator/Expandable.class.php | 25 ++++++++++++++++++++++ classes/Iterator/Normal.class.php | 12 +++++++++++ classes/Iterator/Offset.class.php | 8 +++++++ 5 files changed, 46 insertions(+), 30 deletions(-) create mode 100644 classes/Iterator/Expandable.class.php create mode 100644 classes/Iterator/Normal.class.php create mode 100644 classes/Iterator/Offset.class.php diff --git a/classes/Doctrine.class.php b/classes/Doctrine.class.php index 9cf658930..e65f52bda 100644 --- a/classes/Doctrine.class.php +++ b/classes/Doctrine.class.php @@ -232,6 +232,7 @@ final class Doctrine { case "Session": case "DQL": case "Sensei": + case "Iterator": $a[] = self::$path.DIRECTORY_SEPARATOR.$entry; break; default: diff --git a/classes/Iterator.class.php b/classes/Iterator.class.php index 632b88a81..f61da6348 100644 --- a/classes/Iterator.class.php +++ b/classes/Iterator.class.php @@ -66,36 +66,6 @@ abstract class Doctrine_Iterator implements Iterator { $this->key = $this->keys[$i]; } } -class Doctrine_Iterator_Normal extends Doctrine_Iterator { - /** - * @return boolean whether or not the iteration will continue - */ - public function valid() { - return ($this->index < $this->count); - } -} -class Doctrine_Iterator_Offset extends Doctrine_Iterator { - public function valid() { } -} -class Doctrine_Iterator_Expandable extends Doctrine_Iterator { - public function valid() { - if($this->index < $this->count) - return true; - elseif($this->index == $this->count) { - $coll = $this->collection->expand($this->index); - if($coll instanceof Doctrine_Collection) { - $count = count($coll); - if($count > 0) { - $this->keys = array_merge($this->keys, $coll->getKeys()); - $this->count += $count; - return true; - } - } - - return false; - } - } -} ?> diff --git a/classes/Iterator/Expandable.class.php b/classes/Iterator/Expandable.class.php new file mode 100644 index 000000000..f92d8c424 --- /dev/null +++ b/classes/Iterator/Expandable.class.php @@ -0,0 +1,25 @@ +index < $this->count) + return true; + elseif($this->index == $this->count) { + + $coll = $this->collection->expand($this->index); + + if($coll instanceof Doctrine_Collection) { + $count = count($coll); + if($count > 0) { + $this->keys = array_merge($this->keys, $coll->getKeys()); + $this->count += $count; + return true; + } + } + + return false; + } + } +} +?> diff --git a/classes/Iterator/Normal.class.php b/classes/Iterator/Normal.class.php new file mode 100644 index 000000000..ec4e4b814 --- /dev/null +++ b/classes/Iterator/Normal.class.php @@ -0,0 +1,12 @@ +index < $this->count); + } +} +?> diff --git a/classes/Iterator/Offset.class.php b/classes/Iterator/Offset.class.php new file mode 100644 index 000000000..98ef259e0 --- /dev/null +++ b/classes/Iterator/Offset.class.php @@ -0,0 +1,8 @@ +