From 28b62f5071928d5425e7ac5918d501b9cefdf5cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Sat, 10 Jan 2026 11:31:24 +0100 Subject: [PATCH] feat: adjust xml dump reader command to new filename format --- src/Command/ReadXmlDumpCommand.php | 48 ++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/Command/ReadXmlDumpCommand.php b/src/Command/ReadXmlDumpCommand.php index b22c0be..9950104 100644 --- a/src/Command/ReadXmlDumpCommand.php +++ b/src/Command/ReadXmlDumpCommand.php @@ -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; } - $content = $this->xmlDump->read($filename); - $output->writeln($content); + 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; + } }