|
SPL-StandardPHPLibrary
|


Public Member Functions | |
| __call ($func, $params) | |
| __construct ($path) | |
| beginChildren () | |
| callGetChildren () | |
| callHasChildren () | |
| current () | |
| endChildren () | |
| getDepth () | |
| getInnerIterator () | |
| getSubIterator ($level=NULL) | |
| key () | |
| next () | |
| nextElement () | |
| rewind () | |
| valid () | |
Public Attributes | |
| const | CATCH_GET_CHILD = 0x00000002 |
| const | CHILD_FIRST = 2 |
| const | LEAVES_ONLY = 0 |
| const | SELF_FIRST = 1 |
A tree iterator that only shows directories.
Definition at line 17 of file directorygraphiterator.inc.
| DirectoryGraphIterator::__construct | ( | $ | path | ) |
Construct from a path.
| $path | directory to iterate |
Reimplemented from DirectoryTreeIterator.
Definition at line 19 of file directorygraphiterator.inc.
References CachingIterator\CALL_TOSTRING, CachingIterator\CATCH_GET_CHILD, and RecursiveDirectoryIterator\KEY_AS_FILENAME.
{
RecursiveIteratorIterator::__construct(
new RecursiveCachingIterator(
new ParentIterator(
new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
)
),
CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
),
parent::SELF_FIRST
);
}
| DirectoryTreeIterator::__call | ( | $ | func, |
| $ | params | ||
| ) | [inherited] |
Aggregates the inner iterator.
Definition at line 48 of file directorytreeiterator.inc.
References RecursiveIteratorIterator\getSubIterator().
{
return call_user_func_array(array($this->getSubIterator(), $func), $params);
}

| RecursiveIteratorIterator::beginChildren | ( | ) | [inherited] |
Called right after calling getChildren() and its rewind().
Definition at line 201 of file recursiveiteratoriterator.inc.
Referenced by RecursiveIteratorIterator\next().
{
}
| RecursiveIteratorIterator::callGetChildren | ( | ) | [inherited] |
Definition at line 193 of file recursiveiteratoriterator.inc.
Referenced by RecursiveIteratorIterator\next().
{
return $this->ait[$this->count]->getChildren();
}
| RecursiveIteratorIterator::callHasChildren | ( | ) | [inherited] |
Definition at line 185 of file recursiveiteratoriterator.inc.
Referenced by RecursiveIteratorIterator\callNextElement(), and RecursiveIteratorIterator\next().
{
return $this->ait[$this->count]->hasChildren();
}
| DirectoryTreeIterator::current | ( | ) | [inherited] |
Reimplemented from RecursiveIteratorIterator.
Definition at line 36 of file directorytreeiterator.inc.
References RecursiveIteratorIterator\getDepth(), and RecursiveIteratorIterator\getSubIterator().
{
$tree = '';
for ($l=0; $l < $this->getDepth(); $l++) {
$tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' ';
}
return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-')
. $this->getSubIterator($l)->__toString();
}

| RecursiveIteratorIterator::endChildren | ( | ) | [inherited] |
Called after current child iterator is invalid and right before it gets destructed.
Reimplemented in RecursiveCompareDualIterator.
Definition at line 209 of file recursiveiteratoriterator.inc.
Referenced by RecursiveIteratorIterator\next(), RecursiveIteratorIterator\rewind(), and RecursiveIteratorIterator\valid().
{
}
| RecursiveIteratorIterator::getDepth | ( | ) | [inherited] |
Definition at line 177 of file recursiveiteratoriterator.inc.
Referenced by DirectoryTreeIterator\current(), and RecursiveTreeIterator\getPrefix().
{
return $this->level;
}
| RecursiveIteratorIterator::getInnerIterator | ( | ) | [inherited] |
Implements OuterIterator.
Definition at line 170 of file recursiveiteratoriterator.inc.
Referenced by RecursiveCompareDualIterator\areEqual(), RecursiveCompareDualIterator\areIdentical(), and RecursiveCompareDualIterator\endChildren().
{
return $this->it;
}
| RecursiveIteratorIterator::getSubIterator | ( | $ | level = NULL | ) | [inherited] |
Definition at line 159 of file recursiveiteratoriterator.inc.
Referenced by DirectoryTreeIterator\__call(), RecursiveTreeIterator\__call(), DirectoryTreeIterator\current(), and RecursiveTreeIterator\getPrefix().
{
if (is_null($level)) {
$level = $this->count;
}
return @$this->ait[$level];
}
| RecursiveIteratorIterator::key | ( | ) | [inherited] |
Implements Iterator.
Reimplemented in RecursiveTreeIterator.
Definition at line 91 of file recursiveiteratoriterator.inc.
References $it.
| RecursiveIteratorIterator::next | ( | ) | [inherited] |
Forward to next element.
Implements Iterator.
Definition at line 107 of file recursiveiteratoriterator.inc.
References $it, RecursiveIteratorIterator\beginChildren(), RecursiveIteratorIterator\callGetChildren(), RecursiveIteratorIterator\callHasChildren(), RecursiveIteratorIterator\callNextElement(), and RecursiveIteratorIterator\endChildren().
{
while ($this->count) {
$it = $this->ait[$this->count];
if ($it->valid()) {
if (!$it->recursed && callHasChildren()) {
$it->recursed = true;
try
{
$sub = callGetChildren();
}
catch (Exception $e)
{
if (!($this->flags & self::CATCH_GET_CHILD))
{
throw $e;
}
$it->next();
continue;
}
$sub->recursed = false;
$sub->rewind();
if ($sub->valid()) {
$this->ait[++$this->count] = $sub;
if (!$sub instanceof RecursiveIterator) {
throw new Exception(get_class($sub).'::getChildren() must return an object that implements RecursiveIterator');
}
$this->beginChildren();
return;
}
unset($sub);
}
$it->next();
$it->recursed = false;
if ($it->valid()) {
return;
}
$it->recursed = false;
}
if ($this->count) {
unset($this->ait[$this->count--]);
$it = $this->ait[$this->count];
$this->endChildren();
callNextElement(false);
}
}
callNextElement(true);
}

| RecursiveIteratorIterator::nextElement | ( | ) | [inherited] |
Called when the next element is available.
Definition at line 232 of file recursiveiteratoriterator.inc.
Referenced by RecursiveIteratorIterator\callNextElement().
{
}
| RecursiveIteratorIterator::rewind | ( | ) | [inherited] |
Rewind to top iterator as set in constructor.
Implements Iterator.
Reimplemented in RecursiveCompareDualIterator.
Definition at line 62 of file recursiveiteratoriterator.inc.
References RecursiveIteratorIterator\callNextElement(), and RecursiveIteratorIterator\endChildren().
{
while ($this->count) {
unset($this->ait[$this->count--]);
$this->endChildren();
}
$this->ait[0]->rewind();
$this->ait[0]->recursed = false;
callNextElement(true);
}

| RecursiveIteratorIterator::valid | ( | ) | [inherited] |
Implements Iterator.
Definition at line 75 of file recursiveiteratoriterator.inc.
References RecursiveIteratorIterator\$count, $it, and RecursiveIteratorIterator\endChildren().
Referenced by RecursiveIteratorIterator\callNextElement().
{
$count = $this->count;
while ($count) {
$it = $this->ait[$count];
if ($it->valid()) {
return true;
}
$count--;
$this->endChildren();
}
return false;
}

const RecursiveIteratorIterator::CATCH_GET_CHILD = 0x00000002 [inherited] |
Flag: Catches exceptions during getChildren() calls and simply jumps to the next element.
Definition at line 33 of file recursiveiteratoriterator.inc.
const RecursiveIteratorIterator::CHILD_FIRST = 2 [inherited] |
Mode: Show all children prior to their parent.
Definition at line 29 of file recursiveiteratoriterator.inc.
const RecursiveIteratorIterator::LEAVES_ONLY = 0 [inherited] |
Mode: Only show leaves.
Definition at line 25 of file recursiveiteratoriterator.inc.
const RecursiveIteratorIterator::SELF_FIRST = 1 [inherited] |
Mode: Show parents prior to their children.
Definition at line 27 of file recursiveiteratoriterator.inc.
1.7.5.1