Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FilesCollector.php
Go to the documentation of this file.
1 <?php
7 
12 {
20  public function getFiles(array $paths, $fileMask = false)
21  {
22  $files = [];
23  foreach ($paths as $path) {
24  foreach ($this->_getIterator($path, $fileMask) as $file) {
25  $files[] = (string)$file;
26  }
27  }
28  sort($files);
29  return $files;
30  }
31 
40  protected function _getIterator($path, $fileMask = false)
41  {
42  try {
43  $directoryIterator = new \RecursiveDirectoryIterator(
44  $path,
45  \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::FOLLOW_SYMLINKS
46  );
47  $iterator = new \RecursiveIteratorIterator($directoryIterator);
48  } catch (\UnexpectedValueException $valueException) {
49  throw new \InvalidArgumentException(sprintf('Cannot read directory for parse phrase: "%s".', $path));
50  }
51  if ($fileMask) {
52  $iterator = new \RegexIterator($iterator, $fileMask);
53  }
54  return $iterator;
55  }
56 }
getFiles(array $paths, $fileMask=false)
$paths
Definition: _bootstrap.php:83
foreach($appDirs as $dir) $files