8000 Add an entry on json export format · symfony/symfony@4ad9593 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4ad9593

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

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

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

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,23 @@ 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+
101+
return $carry;
102+
},
103+
array()
104+
);
105+
}
106+
91107
$io->writeln(json_encode($data));
92-
$this->displayAlternatives($this->findWrongBundleOverrides(), $io);
93108

94109
return 0;
95110
}
@@ -130,7 +145,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
130145
array_pop($rows);
131146
$io->section('Loader Paths');
132147
$io->table(array('Namespace', 'Paths'), $rows);
133-
$this->displayAlternatives($this->findWrongBundleOverrides(), $io);
148+
8000 $messages = $this->buildWarningMessages($this->findWrongBundleOverrides());
149+
array_walk(
150+
$messages,
151+
function ($message) use ($io) {
152+
$io->warning(trim($message));
153+
}
154+
);
134155

135156
return 0;
136157
}
@@ -312,8 +333,9 @@ function ($carry, $absolutePath) use ($relativePath) {
312333
return $alternatives;
313334
}
314335

315-
private function displayAlternatives(array $wrongBundles, SymfonyStyle $io): void
336+
private function buildWarningMessages(array $wrongBundles): array
316337
{
338+
$messages = array();
317339
foreach ($wrongBundles as $path => $alternatives) {
318340
$message = sprintf('Path "%s" not matching any bundle found', $path);
319341
if ($alternatives) {
@@ -326,7 +348,9 @@ private function displayAlternatives(array $wrongBundles, SymfonyStyle $io): voi
326348
}
327349
}
328350
}
329-
$io->warning(trim($message));
351+
$messages[] = $message;
330352
}
353+
354+
return $messages;
331355
}
332356
}

0 commit comments

Comments
 (0)
0