Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • CachingIterator
  • Filter
  • InstanceFilter
  • Mapper
  • RecursiveFilter
  • Recursor
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (http://nette.org)
 5:  *
 6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 7:  *
 8:  * For the full copyright and license information, please view
 9:  * the file license.txt that was distributed with this source code.
10:  */
11: 
12: namespace Nette\Iterators;
13: 
14: use Nette;
15: 
16: 
17: /**
18:  * Generic recursive iterator.
19:  *
20:  * @author     David Grudl
21:  */
22: class Recursor extends \IteratorIterator implements \RecursiveIterator, \Countable
23: {
24: 
25:     /**
26:      * Has the current element has children?
27:      * @return bool
28:      */
29:     public function hasChildren()
30:     {
31:         $obj = $this->current();
32:         return ($obj instanceof \IteratorAggregate && $obj->getIterator() instanceof \RecursiveIterator)
33:             || $obj instanceof \RecursiveIterator;
34:     }
35: 
36: 
37:     /**
38:      * The sub-iterator for the current element.
39:      * @return \RecursiveIterator
40:      */
41:     public function getChildren()
42:     {
43:         $obj = $this->current();
44:         return $obj instanceof \IteratorAggregate ? $obj->getIterator() : $obj;
45:     }
46: 
47: 
48:     /**
49:      * Returns the count of elements.
50:      * @return int
51:      */
52:     public function count()
53:     {
54:         return iterator_count($this);
55:     }
56: 
57: }
58: 
Nette Framework 2.0.11 API API documentation generated by ApiGen 2.8.0