Re: svn: /pear2/sandbox/SimpleChannelFrontend/trunk/ src/SimpleChannelFrontend/Categories.php src/SimpleChannelFrontend/Package.php
src/SimpleChannelFrontend/PackageList.php www/templates/Categories.tpl.php www/templates/Package.tpl.php www/templates/PackageList.tpl.php

From: Date: Thu, 19 Nov 2009 19:34:11 +0000
Subject: Re: svn: /pear2/sandbox/SimpleChannelFrontend/trunk/ src/SimpleChannelFrontend/Categories.php src/SimpleChannelFrontend/Package.php
src/SimpleChannelFrontend/PackageList.php www/templates/Categories.tpl.php www/templates/Package.tpl.php www/templates/PackageList.tpl.php
References: 1  Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-9040@lists.php.net to get a copy of this message
Brett Bieber wrote: > saltybeagle Thu, 19 Nov 2009 16:33:58 +0000 > > Revision: > http://svn.php.net/viewvc?view=revision&revision=291011 > > <snip> > Modified: pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Package.php > =================================================================== > --- pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Package.php 2009-11-19 > 16:31:24 UTC (rev 291010) > +++ pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Package.php 2009-11-19 > 16:33:58 UTC (rev 291011) > @@ -1,12 +1,66 @@ > <?php > namespace pear2\SimpleChannelFrontend; > -class Package > +class Package implements \ArrayAccess, \Iterator > { > - public $package; > + public $_package; > > function __construct($options = array()) > { > - $this->package = > $options['frontend']::$channel->remotepackage[$options['package']]; > + $this->_package = > $options['frontend']::$channel->remotepackage[$options['package']]; > } > + > + function __get($var) > + { > + return $this->_package->$var; > + } > + > + function __call($method, $args) > + { > + return call_user_func_array(array($this->_package, $method), $args); > + } > + > + function offsetExists($offset) > + { > + return $this->_package->offsetExists($offset); > + } > + > + function offsetGet($offset) > + { > + return $this->_package->offsetGet($offset); > + } > + > + function offsetSet($offset, $val) > + { > + return $this->_package->offsetSet($offset, $val); > + } > + > + function offsetUnset($offset) > + { > + return $this->_package->offsetUnset($offset); > + } > + > + function current() > + { > + return $this->_package->current(); > + } > + > + function next() > + { > + return $this->_package->next(); > + } > + > + function key() > + { > + return $this->_package->key(); > + } > + > + function valid() > + { > + return $this->_package->valid(); > + } > + > + function rewind() > + { > + return $this->_package->rewind(); > + } > } > -?> > \ No newline at end of file > Nice work as always :) A small tip that can save a few lines of code: instead of implementing Iterator, implement InnerIterator: function getIterator() { return $this->_package; } Greg

« previous php.pear.core (#9040) next »