feat: adjust xml dump reader command to new filename format
This commit is contained in:
@@ -49,17 +49,22 @@ class ReadXmlDumpCommand extends Command
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$filename = $requestId.'_'.$type.'.xml';
|
||||
|
||||
try {
|
||||
if (false === $this->xmlDump->fileExists($filename)) {
|
||||
$io->warning(sprintf('Dump file "%s" not found. It may have been cleaned up.', $filename));
|
||||
$files = $this->findMatchingFiles($requestId, $type);
|
||||
|
||||
if (0 === count($files)) {
|
||||
$io->warning(sprintf('No dump files found for request ID "%s". They may have been cleaned up.', $requestId));
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
foreach ($files as $filename) {
|
||||
if (count($files) > 1) {
|
||||
$io->section($filename);
|
||||
}
|
||||
$content = $this->xmlDump->read($filename);
|
||||
$output->writeln($content);
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
} catch (FilesystemException $e) {
|
||||
@@ -68,4 +73,35 @@ class ReadXmlDumpCommand extends Command
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds dump files matching the given request ID and type.
|
||||
*
|
||||
* Supports both exact matches (e.g., "abc123_1") and base ID matches (e.g., "abc123")
|
||||
* which will return all files with counter suffixes.
|
||||
*
|
||||
* @return string[]
|
||||
*
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
private function findMatchingFiles(string $requestId, string $type): array
|
||||
{
|
||||
$exactMatch = $requestId.'_'.$type.'.xml';
|
||||
if ($this->xmlDump->fileExists($exactMatch)) {
|
||||
return [$exactMatch];
|
||||
}
|
||||
|
||||
$pattern = '/^'.preg_quote($requestId, '/').'_\d+_'.$type.'\.xml$/';
|
||||
$matches = [];
|
||||
|
||||
foreach ($this->xmlDump->listContents('.') as $item) {
|
||||
if ($item->isFile() && 1 === preg_match($pattern, $item->path())) {
|
||||
$matches[] = $item->path();
|
||||
}
|
||||
}
|
||||
|
||||
sort($matches);
|
||||
|
||||
return $matches;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user