Packages

  • 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

  • GenericRecursiveIterator
  • InstanceFilterIterator
  • MapIterator
  • NCallbackFilterIterator
  • NRecursiveCallbackFilterIterator
  • SmartCachingIterator
  • Overview
  • Package
  • 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:  * @package Nette\Iterators
11:  */
12: 
13: 
14: 
15: /**
16:  * Callback recursive iterator filter.
17:  *
18:  * @author     David Grudl
19:  * @package Nette\Iterators
20:  */
21: class NRecursiveCallbackFilterIterator extends FilterIterator implements RecursiveIterator
22: {
23:     /** @var callable */
24:     private $callback;
25: 
26:     /** @var callable */
27:     private $childrenCallback;
28: 
29: 
30:     public function __construct(RecursiveIterator $iterator, $callback, $childrenCallback = NULL)
31:     {
32:         parent::__construct($iterator);
33:         $this->callback = $callback === NULL ? NULL : new Callback($callback);
34:         $this->childrenCallback = $childrenCallback === NULL ? NULL : new Callback($childrenCallback);
35:     }
36: 
37: 
38:     public function accept()
39:     {
40:         return $this->callback === NULL || $this->callback->invoke($this);
41:     }
42: 
43: 
44:     public function hasChildren()
45:     {
46:         return $this->getInnerIterator()->hasChildren()
47:             && ($this->childrenCallback === NULL || $this->childrenCallback->invoke($this));
48:     }
49: 
50: 
51:     public function getChildren()
52:     {
53:         return new self($this->getInnerIterator()->getChildren(), $this->callback, $this->childrenCallback);
54:     }
55: 
56: }
57: 
Nette Framework 2.0.13 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.8.0