Skip to content

Commit 637598d

Browse files
author
Pascal Montoya
committed
Add an entry on json export format
1 parent 805868c commit 637598d

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
8888
}
8989
$data['tests'] = array_keys($data['tests']);
9090
$data['loader_paths'] = $this->getLoaderPaths();
91+
$wrongBundles = $this->findWrongBundleOverrides();
92+
if ($wrongBundles) {
93+
$data['warnings'] = array();
94+
95+
$messages = $this->buildWarningMessages($this->findWrongBundleOverrides());
96+
$data['warnings'] = array_reduce(
97+
$messages,
98+
function ($carry, $message) {
99+
$carry[] = $message;
100+
return $carry;
101+
},
102+
array()
103+
);
104+
}
105+
91106
$io->writeln(json_encode($data));
92-
$this->displayAlternatives($this->findWrongBundleOverrides(), $io);
93107

94108
return 0;
95109
}
@@ -130,7 +144,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
130144
array_pop($rows);
131145
$io->section('Loader Paths');
132146
$io->table(array('Namespace', 'Paths'), $rows);
133-
$this->displayAlternatives($this->findWrongBundleOverrides(), $io);
147+
$messages = $this->buildWarningMessages($this->findWrongBundleOverrides());
148+
array_walk(
149+
$messages,
150+
function ($message) use ($io) {
151+
$io->warning(trim($message));
152+
}
153+
);
134154

135155
return 0;
136156
}
@@ -312,8 +332,9 @@ function ($carry, $absolutePath) use ($relativePath) {
312332
return $alternatives;
313333
}
314334

315-
private function displayAlternatives(array $wrongBundles, SymfonyStyle $io): void
335+
private function buildWarningMessages(array $wrongBundles): array
316336
{
337+
$messages = array();
317338
foreach ($wrongBundles as $path => $alternatives) {
318339
$message = sprintf('Path "%s" not matching any bundle found', $path);
319340
if ($alternatives) {
@@ -326,7 +347,9 @@ private function displayAlternatives(array $wrongBundles, SymfonyStyle $io): voi
326347
}
327348
}
328349
}
329-
$io->warning(trim($message));
350+
$messages[] = $message;
330351
}
352+
353+
return $messages;
331354
}
332355
}

0 commit comments

Comments
 (0)