Back to index

php5  5.3.10
recursivecachingiterator.inc
Go to the documentation of this file.
00001 <?php
00002 
00020 class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
00021 {
00022        private $hasChildren;
00023        private $getChildren;
00024 
00032        function __construct(RecursiveIterator $it, $flags = self::CALL_TOSTRING)
00033        {
00034               parent::__construct($it, $flags);
00035        }
00036 
00039        function rewind();
00040        {
00041           $this->hasChildren = false;
00042           $this->getChildren = NULL;
00043           parent::rewind();
00044        }
00045 
00049        function next()
00050        {
00051               if ($this->hasChildren = $this->it->hasChildren())
00052               {
00053                      try
00054                      {
00055                             $child = $this->it->getChildren();
00056                             if (!$this->ref)
00057                             {
00058                                    $this->ref = new ReflectionClass($this);
00059                             }
00060                             $this->getChildren = $ref->newInstance($child, $this->flags);
00061                      }
00062                      catch(Exception $e)
00063                      {
00064                             if (!$this->flags & self::CATCH_GET_CHILD)
00065                             {
00066                                    throw $e;
00067                             }
00068                             $this->hasChildren = false;
00069                             $this->getChildren = NULL;
00070                      }
00071               } else
00072               {
00073                      $this->getChildren = NULL;
00074               }
00075               parent::next();
00076        }
00077        
00078        private $ref;
00079 
00086        function hasChildren()
00087        {
00088               return $this->hasChildren;
00089        }
00090 
00093        function getChildren()
00094        {
00095               return $this->getChildren;
00096        }
00097 }
00098 
00099 ?>