TYPO3  7.6
ExcludeDirectoryFilterIterator.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Symfony\Component\Finder\Iterator;
13 
20 {
21  private $patterns = array();
22 
29  public function __construct(\Iterator $iterator, array $directories)
30  {
31  foreach ($directories as $directory) {
32  $this->patterns[] = '#(^|/)'.preg_quote($directory, '#').'(/|$)#';
33  }
34 
35  parent::__construct($iterator);
36  }
37 
43  public function accept()
44  {
45  $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
46  $path = str_replace('\\', '/', $path);
47  foreach ($this->patterns as $pattern) {
48  if (preg_match($pattern, $path)) {
49  return false;
50  }
51  }
52 
53  return true;
54  }
55 }