Skip to content
Snippets Groups Projects
Commit 5705f30e authored by Ere Maijala's avatar Ere Maijala Committed by Robert Lange
Browse files

Sort filenames in MergeMarcCommand.

parent 7418d962
No related merge requests found
...@@ -89,18 +89,23 @@ class MergeMarcCommand extends RelativeFileAwareCommand ...@@ -89,18 +89,23 @@ class MergeMarcCommand extends RelativeFileAwareCommand
} }
$output->writeln('<collection>'); $output->writeln('<collection>');
$fileList = [];
while (false !== ($file = readdir($handle))) { while (false !== ($file = readdir($handle))) {
// Only operate on XML files: // Only operate on XML files:
if (pathinfo($file, PATHINFO_EXTENSION) === "xml") { if (pathinfo($file, PATHINFO_EXTENSION) === "xml") {
// get file content // get file content
$filePath = $dir . '/' . $file; $fileList[] = $dir . '/' . $file;
$fileContent = file_get_contents($filePath);
// output content:
$output->writeln("<!-- $filePath -->");
$output->write($fileContent);
} }
} }
// Sort filenames so that we have consistent results:
sort($fileList);
foreach ($fileList as $filePath) {
$fileContent = file_get_contents($filePath);
// output content:
$output->writeln("<!-- $filePath -->");
$output->write($fileContent);
}
$output->writeln('</collection>'); $output->writeln('</collection>');
return 0; return 0;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment