Hi, Tks for everything, now up and running:
class BurnModelIterator implements Iterator { protected $obj, $current; public function __construct(PhpBURN_Core $obj) { $this->obj = &$obj; } function rewind() { $this->obj->_moveFirst(); } function current() { return $this->current = $this->obj; } function key() { return $this->obj->getDialect()->getPointer(); } function next() { return $this->obj->fetch(); } function valid() { if($this->obj->getDialect()->getPointer() > $this->obj->getDialect()->getLast() ) { return false; } else { return true; } } :) Best Regards Klederson Bueno www.phpburn.com 2010/7/29 Kornel Lesiński <kor...@aardvarkmedia.co.uk> > On 29-07-2010 at 16:09:52 Klederson Bueno <kleder...@klederson.com> wrote: > > I have this framework ( www.phpburn.com ) and while i do: $obj->fetch() >> it >> returns true or false until while ends... however repeat works more as a >> foreach and then i cant use this... how can i work with repeat working as >> a while ? >> > > You can wrap it in an iterator: > > class WhileIterator implements Iterator > { > protected $current, $obj; > > function __construct($obj) > { > $this->obj = $obj; > } > > function next() > { > $this->current = $this->obj->fetch() ? you_get_next_object_here() : > false; > } > > function current() > { > return $this->current; > } > > function key() > { > return 'implement if you care'; > } > > function valid() > { > return !!$this->current; > } > > function rewind() > { > $this->next(); // loads first object > } > } > > > You can also make custom expression modifier: > > function phptal_tales_while($expr, $nothrow) > { > return 'new WhileIterator('.phptal_tale($expr,$nothrow).')'; > } > > and then use tal:repeat="x while:obj" > > -- > regards, Kornel > > _______________________________________________ > PHPTAL mailing list > PHPTAL@lists.motion-twin.com > http://lists.motion-twin.com/mailman/listinfo/phptal >
_______________________________________________ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal