-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DX] Remove default match from AbstractConfigCommand::findExtension #17456
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The build failure seems unrelated to this PR: https://travis-ci.org/symfony/symfony/jobs/103599240#L3252 |
What about rewriting this like: $bundles = $this->initializeBundles();
foreach ($bundles as $bundle) {
if ($name === $bundle->getName()) {
return $bundle->getContainerExtension();
}
$extension = $bundle->getContainerExtension();
if ($extension && $name === $extension->getAlias()) {
return $extension;
}
}
if ('Bundle' !== substr($name -6)) {
$message = sprintf('No extensions with configuration available for "%s"', $name);
} else {
$message = sprintf('No extension with alias "%s" is enabled', $name);
}
throw new \LogicException($message);
} |
@wouterj, good idea, will update the PR. I just thought it could be better if less code was rewritten, but now I have to agree your code looks better :) |
7fd1d07
to
f797e12
Compare
Previously, findExtension would return the first extension that might not even match the $name parameter.
f797e12
to
ea1ded8
Compare
👍 |
Status: reviewed |
Thank you @kix. |
fabpot
added a commit
that referenced
this pull request
Jan 21, 2016
…Extension (kix) This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #17456). Discussion ---------- [DX] Remove default match from AbstractConfigCommand::findExtension | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | none Previously, `findExtension` would return the first extension that might not even match the `$name` parameter, which would quite confuse the user: ``` $ app/console config:debug TotallyNonExistentBundle # Current configuration for "TotallyNonExistentBundle" knp_paginator: default_options: sort_field_name: sort sort_direction_name: direction filter_field_name: filterField filter_value_name: filterValue page_name: page distinct: true template: pagination: 'KnpPaginatorBundle:Pagination:sliding.html.twig' filtration: 'KnpPaginatorBundle:Pagination:filtration.html.twig' sortable: 'KnpPaginatorBundle:Pagination:sortable_link.html.twig' page_range: 5 ``` Same problem goes for the `config:dump` command. When you dumped the config for a bundle you thought you've registered, but, for example, you'd use a name that's not exactly matching, you'd get confusing output for a different bundle's configuration. The problem was, an `Extension` [was always fetched in the finder method](https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php#L51), and name/alias misses were ignored. Commits ------- b85059a Remove default match from AbstractConfigCommand::findExtension
Thanks for merging! |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously,
findExtension
would return the first extension that might not even match the$name
parameter, which would quite confuse the user:Same problem goes for the
config:dump
command. When you dumped the config for a bundle you thought you've registered, but, for example, you'd use a name that's not exactly matching, you'd get confusing output for a different bundle's configuration.The problem was, an
Extension
was always fetched in the finder method, and name/alias misses were ignored.