SPL-StandardPHPLibrary
Public Member Functions | Protected Member Functions | Private Attributes
RecursiveFilterIterator Class Reference
Inheritance diagram for RecursiveFilterIterator:
Inheritance graph
[legend]
Collaboration diagram for RecursiveFilterIterator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 __call ($func, $params)
 __construct (RecursiveIterator $it)
 accept ()
 current ()
 getChildren ()
 getInnerIterator ()
 hasChildren ()
 key ()
 next ()
 rewind ()
 valid ()

Protected Member Functions

 __clone ()
 fetch ()

Private Attributes

 $ref

Detailed Description

Iterator to filter recursive iterators.

Author:
Marcus Boerger
Version:
1.0
Since:
PHP 5.1

Passes the RecursiveIterator interface to the inner Iterator and provides the same functionality as FilterIterator. This allows you to skip parents and all their childs before loading them all. You need to care about function getChildren() because it may not always suit your needs. The builtin behavior uses reflection to return a new instance of the exact same class it is called from. That is you extend RecursiveFilterIterator and getChildren() will create instance of that class. The problem is that doing this does not transport any state or control information of your accept() implementation to the new instance. To overcome this problem you might need to overwrite getChildren(), call this implementation and pass the control vaules manually.

Definition at line 30 of file recursivefilteriterator.inc.


Constructor & Destructor Documentation

RecursiveFilterIterator::__construct ( RecursiveIterator it)
Parameters:
$itthe RecursiveIterator to filter

Definition at line 34 of file recursivefilteriterator.inc.


Member Function Documentation

FilterIterator::__call ( func,
params 
) [inherited]

Aggregate the inner iterator.

Parameters:
funcName of method to invoke
paramsArray of parameters to pass to method

Reimplemented in SearchIterator.

Definition at line 121 of file filteriterator.inc.

    {
        return call_user_func_array(array($this->it, $func), $params);
    }
FilterIterator::__clone ( ) [protected, inherited]

hidden __clone

Reimplemented in KeyFilter.

Definition at line 104 of file filteriterator.inc.

                                 {
        // disallow clone 
    }
FilterIterator::accept ( ) [abstract, inherited]

Accept function to decide whether an element of the inner iterator should be accessible through the Filteriterator.

Returns:
whether or not to expose the current element of the inner iterator.

Reimplemented in RegexIterator, CallbackFilterIterator, FindFile, KeyFilter, RegexFindFile, DirectoryFilterDots, and ParentIterator.

Referenced by FilterIterator\fetch().

FilterIterator::current ( ) [inherited]
Returns:
The current value

Implements Iterator.

Reimplemented in RegexIterator, CallbackFilterIterator, and IniGroups.

Definition at line 97 of file filteriterator.inc.

Referenced by RegexFindFile\accept(), and FindFile\accept().

                       {
        return $this->it->current();
    }
FilterIterator::fetch ( ) [protected, inherited]

Fetch next element and store it.

Returns:
void

Definition at line 61 of file filteriterator.inc.

References FilterIterator\accept().

Referenced by FilterIterator\next(), and FilterIterator\rewind().

                               {
        while ($this->it->valid()) {
            if ($this->accept()) {
                return;
            }
            $this->it->next();
        };
    }

Here is the call graph for this function:

RecursiveFilterIterator::getChildren ( )
Returns:
an iterator for the current elements children
Note:
the returned iterator will be of the same class as $this

Implements RecursiveIterator.

Definition at line 50 of file recursivefilteriterator.inc.

References FilterIterator\getInnerIterator().

    {
        if (empty($this->ref))
        {
            $this->ref = new ReflectionClass($this);
        }
        return $this->ref->newInstance($this->getInnerIterator()->getChildren());
    }

Here is the call graph for this function:

FilterIterator::getInnerIterator ( ) [inherited]
RecursiveFilterIterator::hasChildren ( )
Returns:
whether the current element has children

Implements RecursiveIterator.

Definition at line 41 of file recursivefilteriterator.inc.

References FilterIterator\getInnerIterator().

    {
        return $this->getInnerIterator()->hasChildren();
    }

Here is the call graph for this function:

FilterIterator::key ( ) [inherited]
Returns:
The current key

Implements Iterator.

Reimplemented in RegexIterator, CallbackFilterIterator, IniGroups, and DirectoryFilterDots.

Definition at line 90 of file filteriterator.inc.

Referenced by KeyFilter\accept().

                   {
        return $this->it->key();
    }
FilterIterator::next ( ) [inherited]

Move to next element.

Returns:
void

Implements Iterator.

Reimplemented in SearchIterator.

Definition at line 75 of file filteriterator.inc.

References FilterIterator\fetch().

                    {
        $this->it->next();
        $this->fetch();
    }

Here is the call graph for this function:

FilterIterator::rewind ( ) [inherited]

Rewind the inner iterator.

Implements Iterator.

Reimplemented in SearchIterator.

Definition at line 42 of file filteriterator.inc.

References FilterIterator\fetch().

                      { 
        $this->it->rewind();
        $this->fetch();
    }

Here is the call graph for this function:

FilterIterator::valid ( ) [inherited]
Returns:
Whether more elements are available

Implements Iterator.

Reimplemented in SearchIterator.

Definition at line 83 of file filteriterator.inc.

                     {
        return $this->it->valid();
    }

Member Data Documentation

RecursiveFilterIterator::$ref [private]

Definition at line 59 of file recursivefilteriterator.inc.


The documentation for this class was generated from the following file: