Permalink
Browse files

Rename ObjectProxy\Iterator to ObjectProxy\Traversable, and use this …

…for every Traversable object. Use \IteratorAggregate to simplify.
  • Loading branch information...
1 parent 863340d commit 6694da32dbcc14a214fc44285405758378390633 @saltybeagle saltybeagle committed Nov 19, 2009
@@ -665,7 +665,11 @@ protected function renderObject($object, $template = null)
{
if ($this->__config['escape']
&& !$object instanceof ObjectProxy) {
- $object = new ObjectProxy($object, $this);
+ if ($object instanceof \Traversable) {
+ $object = new ObjectProxy\Traversable($object, $this);
+ } else {
+ $object = new ObjectProxy($object, $this);
+ }
}
return $this->fetch($object, $template);
}
@@ -68,8 +68,8 @@ function __get($var)
$var = $this->object->$var;
switch(gettype($var)) {
case 'object':
- if ($var instanceof \Iterator) {
- return new ObjectProxy\Iterator($var, $this->savant);
+ if ($var instanceof \Traversable) {
+ return new ObjectProxy\Traversable($var, $this->savant);
}
return new self($var, $this->savant);
case 'string':
@@ -1,30 +0,0 @@
-<?php
-namespace pear2\Templates\Savant\ObjectProxy;
-use pear2\Templates\Savant\ObjectProxy;
-class Iterator extends ObjectProxy implements \Iterator
-{
- function current()
- {
- return $this->object->current();
- }
-
- function next()
- {
- return $this->object->next();
- }
-
- function key()
- {
- return $this->object->key();
- }
-
- function valid()
- {
- return $this->object->valid();
- }
-
- function rewind()
- {
- return $this->object->rewind();
- }
-}
@@ -0,0 +1,10 @@
+<?php
+namespace pear2\Templates\Savant\ObjectProxy;
+use pear2\Templates\Savant\ObjectProxy;
+class Traversable extends ObjectProxy implements \IteratorAggregate
+{
+ function getIterator()
+ {
+ return $this->object;
+ }
+}

0 comments on commit 6694da3

Please sign in to comment.