1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13:
14:
15: 16: 17: 18: 19:
20: class RecursiveCallbackFilterIterator extends FilterIterator implements RecursiveIterator
21: {
22:
23: private $callback;
24:
25:
26: private $childrenCallback;
27:
28:
29: 30: 31: 32: 33:
34: function __construct(RecursiveIterator $iterator, $callback, $childrenCallback = NULL)
35: {
36: parent::__construct($iterator);
37: $this->callback = $callback;
38: $this->childrenCallback = $childrenCallback;
39: }
40:
41:
42:
43: function accept()
44: {
45: return $this->callback === NULL || call_user_func($this->callback, $this);
46: }
47:
48:
49:
50: function hasChildren()
51: {
52: return $this->getInnerIterator()->hasChildren()
53: && ($this->childrenCallback === NULL || call_user_func($this->childrenCallback, $this));
54: }
55:
56:
57:
58: function getChildren()
59: {
60: return new self($this->getInnerIterator()->getChildren(), $this->callback, $this->childrenCallback);
61: }
62:
63: }
64: