-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBridge] Added bundle name suggestion on wrongly overrided templates paths #26919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
1758de2
bab9d99
7d9467a
da0c589
da42b3e
acfb325
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,8 +88,20 @@ protected function execute(InputInterface $input, OutputInterface $output) | |
} | ||
$data['tests'] = array_keys($data['tests']); | ||
$data['loader_paths'] = $this->getLoaderPaths(); | ||
if ($wrongBundles = $this->findWrongBundleOverrides()) { | ||
$messages = $this->buildWarningMessages($wrongBundles); | ||
$data['warnings'] = array_reduce( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure I understand for what we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. It was just dead code. Done |
||
$messages, | ||
function ($carry, $message) { | ||
$carry[] = $message; | ||
|
||
return $carry; | ||
}, | ||
array() | ||
); | ||
} | ||
|
||
$io->writeln(json_encode($data)); | ||
$this->displayAlternatives($this->findWrongBundleOverrides(), $io); | ||
|
||
return 0; | ||
} | ||
|
@@ -130,7 +142,13 @@ protected function execute(InputInterface $input, OutputInterface $output) | |
array_pop($rows); | ||
$io->section('Loader Paths'); | ||
$io->table(array('Namespace', 'Paths'), $rows); | ||
$this->displayAlternatives($this->findWrongBundleOverrides(), $io); | ||
$messages = $this->buildWarningMessages($this->findWrongBundleOverrides()); | ||
array_walk( | ||
$messages, | ||
function ($message) use ($io) { | ||
$io->warning(trim($message)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we just trim in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
); | ||
|
||
return 0; | ||
} | ||
|
@@ -293,13 +311,12 @@ function ($carry, $absolutePath) use ($relativePath) { | |
} | ||
|
||
if (\count($bundleNames)) { | ||
$loadedBundles = $this->bundlesMetadata; | ||
$notFoundBundles = array_diff_key($bundleNames, $loadedBundles); | ||
$notFoundBundles = array_diff_key($bundleNames, $this->bundlesMetadata); | ||
if (\count($notFoundBundles)) { | ||
$alternatives = array(); | ||
foreach ($notFoundBundles as $notFoundBundle => $path) { | ||
$alternatives[$path] = array(); | ||
foreach ($loadedBundles as $name => $bundle) { | ||
foreach ($this->bundlesMetadata as $name => $bundle) { | ||
$lev = levenshtein($notFoundBundle, $name); | ||
if ($lev <= \strlen($notFoundBundle) / 3 || false !== strpos($name, $notFoundBundle)) { | ||
$alternatives[$path][] = $name; | ||
|
@@ -312,8 +329,9 @@ function ($carry, $absolutePath) use ($relativePath) { | |
return $alternatives; | ||
} | ||
|
||
private function displayAlternatives(array $wrongBundles, SymfonyStyle $io): void | ||
private function buildWarningMessages(array $wrongBundles): array | ||
{ | ||
$messages = array(); | ||
foreach ($wrongBundles as $path => $alternatives) { | ||
$message = sprintf('Path "%s" not matching any bundle found', $path); | ||
if ($alternatives) { | ||
|
@@ -326,7 +344,9 @@ private function displayAlternatives(array $wrongBundles, SymfonyStyle $io): voi | |
} | ||
} | ||
} | ||
$io->warning(trim($message)); | ||
$messages[] = $message; | ||
} | ||
|
||
return $messages; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be an item under a to be added
4.2.0
sectionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Thank you