public function getListOfConfigFilesIn($directory, $pattern)
{
// does the directory exist?
if (!is_dir($directory)) {
return [];
}
// use the SPL to do the heavy lifting
$dirIter = new RecursiveDirectoryIterator($directory);
$recIter = new RecursiveIteratorIterator($dirIter);
$regIter = new RegexIterator($recIter, '|^.+' . $pattern . '$|i', RegexIterator::GET_MATCH);
// what happened?
$filenames = [];
foreach ($regIter as $match) {
$filenames[] = $match[0];
}
// let's get the list into some semblance of order
sort($filenames);
// all done
return $filenames;
}