PMCORE-618

This commit is contained in:
Paula Quispe
2022-04-19 15:25:47 -04:00
parent e79f5ac1cc
commit 241b62a3d6

View File

@@ -332,21 +332,26 @@ class AuditLog
*/ */
private function getFiles($path, $pattern = '', $dir = 'ASC') private function getFiles($path, $pattern = '', $dir = 'ASC')
{ {
$finder = new Finder(); try {
$finder->files() $finder = new Finder();
->in($path) $finder->files()
->name($pattern); ->in($path)
$files = iterator_to_array($finder->getIterator()); ->name($pattern);
uasort($files, function ($a, $b) use ($dir) { $files = iterator_to_array($finder->getIterator());
$name1 = $a->getFilename(); uasort($files, function ($a, $b) use ($dir) {
$name2 = $b->getFilename(); $name1 = $a->getFilename();
if ($dir === 'ASC') { $name2 = $b->getFilename();
return strcmp($name1, $name2); if ($dir === 'ASC') {
} else { return strcmp($name1, $name2);
return strcmp($name2, $name1); } else {
} return strcmp($name2, $name1);
}); }
return $files; });
return $files;
} catch (Exception $e) {
// Return array empty when the path does not exist
return [];
}
} }
/** /**