1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
<?php
/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/
namespace Nette\ComponentModel;
/**
* Recursive component iterator. See Container::getComponents().
* @internal
*/
class RecursiveComponentIterator extends \RecursiveArrayIterator implements \Countable
{
/**
* Has the current element has children?
* @return bool
*/
public function hasChildren()
{
return $this->current() instanceof IContainer;
}
/**
* The sub-iterator for the current element.
* @return \RecursiveIterator
*/
public function getChildren()
{
return $this->current()->getComponents();
}
/**
* Returns the count of elements.
* @return int
*/
public function count()
{
return iterator_count($this);
}
}
|