Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
CustomFilterIterator.php
01 <?php
02
03 /*
04 * This file is part of the Symfony package.
05 *
06 * (c) Fabien Potencier <fabien@symfony.com>
07 *
08 * For the full copyright and license information, please view the LICENSE
09 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Finder\Iterator;
13
14 /**
15 * CustomFilterIterator filters files by applying anonymous functions.
16 *
17 * The anonymous function receives a \SplFileInfo and must return false
18 * to remove files.
19 *
20 * @author Fabien Potencier <fabien@symfony.com>
21 */
22 class CustomFilterIterator extends FilterIterator
23 {
24 private $filters = [];
25
26 /**
27 * @param \Iterator $iterator The Iterator to filter
28 * @param callable[] $filters An array of PHP callbacks
29 *
30 * @throws \InvalidArgumentException
31 */
32 public function __construct(\Iterator $iterator, array $filters)
33 {
34 foreach ($filters as $filter) {
35 if (!\is_callable($filter)) {
36 throw new \InvalidArgumentException('Invalid PHP callback.');
37 }
38 }
39 $this->filters = $filters;
40
41 parent::__construct($iterator);
42 }
43
44 /**
45 * Filters the iterator values.
46 *
47 * @return bool true if the value should be kept, false otherwise
48 */
49 public function accept()
50 {
51 $fileinfo = $this->current();
52
53 foreach ($this->filters as $filter) {
54 if (false === \call_user_func($filter, $fileinfo)) {
55 return false;
56 }
57 }
58
59 return true;
60 }
61 }
62