Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Component\FileSystem;
|
||||
|
||||
/**
|
||||
* Iterates over files whose names match a regular expression in a directory.
|
||||
*/
|
||||
class RegexDirectoryIterator extends \FilterIterator {
|
||||
|
||||
/**
|
||||
* The regular expression to match.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $regex;
|
||||
|
||||
/**
|
||||
* RegexDirectoryIterator constructor.
|
||||
*
|
||||
* @param string $path
|
||||
* The path to scan.
|
||||
* @param string $regex
|
||||
* The regular expression to match, including delimiters. For example,
|
||||
* /\.yml$/ would list only files ending in .yml.
|
||||
*/
|
||||
public function __construct($path, $regex) {
|
||||
// Use FilesystemIterator to not iterate over the the . and .. directories.
|
||||
$iterator = new \FilesystemIterator($path);
|
||||
parent::__construct($iterator);
|
||||
$this->regex = $regex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \FilterIterator::accept().
|
||||
*/
|
||||
public function accept() {
|
||||
/** @var \SplFileInfo $file_info */
|
||||
$file_info = $this->getInnerIterator()->current();
|
||||
return $file_info->isFile() && preg_match($this->regex, $file_info->getFilename());
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue