Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Config] More accurate message on invalid config builder #40994

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

Merged
merged 1 commit into from
May 2, 2021

Conversation

a-menshchikov
Copy link
Contributor

Q A
Branch? 5.x
Bug fix? no
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

Throw exception when trying to autowire nested bundle config instead of ConfigBuilder (related Doc PR symfony/symfony-docs#15300).
Also renamed test class AcmeConfigBuilder to AcmeConfig according config builders auto naming.

Inspired by a chat with @Nyholm

@derrabus derrabus requested a review from Nyholm April 29, 2021 21:03
@carsonbot carsonbot changed the title More accurate message on invalid config builder [Config] More accurate message on invalid config builder Apr 29, 2021
@derrabus derrabus added this to the 5.3 milestone Apr 29, 2021
Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Well done with the tests!

}

// Try to get the extension alias
$alias = Container::underscore(substr($namespace, 15, -6));

if (false !== strpos($alias, '\\')) {
throw new InvalidArgumentException(sprintf('Nested bundle config class "%s" could not be handled.', $namespace));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, we are not talking about "bundles" but "extensions".

Could we be more descriptive here?

Something more similar to this?

Could not find or generate class "%s". Make sure to use the "root" ConfigBuilder class. Ie use "Symfony\Config\FrameworkConfig" and not Symfony\Config\Framework\CacheConfig"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to make message more descriptive, but without concrete classes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. I missed this comment.

I do agree that not using Symfony\Config\Framework\CacheConfig may be better, but it is also very hard to understand what "nested classes" really mean. Im not sure that my suggestion is the best.

Throw exception when try to autowire nested bundle config instead of ConfigBuilder.
Also renamed test class AcmeConfigBuilder to AcmeConfig according config builders auto naming.
@a-menshchikov a-menshchikov requested a review from Nyholm April 30, 2021 09:49
Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

Im happy with this PR. I just had one small question left.

@derrabus
Copy link
Member

derrabus commented May 2, 2021

Thank you @a-menshchikov.

@derrabus derrabus merged commit 9857fae into symfony:5.x May 2, 2021
@a-menshchikov a-menshchikov deleted the nested_bundle_config branch May 2, 2021 19:12
@fabpot fabpot mentioned this pull request May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants