-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Config] Introduce find method in ArrayNodeDefinition to ease configuration tree manipulation #31287
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
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
OskarStark
reviewed
Apr 27, 2019
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.
Nice improvement, I like it 👌🏻
I left some minor comments
src/Symfony/Component/Config/Tests/Definition/Builder/NodeFinderTest.php
Outdated
Show resolved
Hide resolved
232d69b
to
d4d7328
Compare
OskarStark
reviewed
Apr 28, 2019
src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Config/Tests/Definition/Builder/NodeFinderTest.php
Outdated
Show resolved
Hide resolved
OskarStark
approved these changes
Apr 28, 2019
b0433f3
to
ef7c09c
Compare
ec0306c
to
4486d96
Compare
4486d96
to
2522f44
Compare
xabbuh
reviewed
Jun 8, 2019
ro0NL
reviewed
Jun 8, 2019
src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
Outdated
Show resolved
Hide resolved
27ab9da
to
f78752f
Compare
f78752f
to
f074903
Compare
xabbuh
requested changes
Jun 9, 2019
src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
Outdated
Show resolved
Hide resolved
f964c12
to
7292bf7
Compare
7292bf7
to
5c32f60
Compare
ro0NL
reviewed
Jun 11, 2019
src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php
Outdated
Show resolved
Hide resolved
xabbuh
approved these changes
Jun 11, 2019
ro0NL
approved these changes
Jun 11, 2019
fabpot
approved these changes
Jun 14, 2019
…ration tree manipulation
cf049b5
to
e3b248a
Compare
Thank you @jschaedl. |
fabpot
added a commit
that referenced
this pull request
Jun 14, 2019
…to ease configuration tree manipulation (jschaedl) This PR was squashed before being merged into the 4.4 branch (closes #31287). Discussion ---------- [Config] Introduce find method in ArrayNodeDefinition to ease configuration tree manipulation | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #27534 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | tbd. ### Description This PR introduces a new `find(string $nodePath)`method in the `ArrayNodeDefinition` class, which helps you finding the right node to prepend configuration to ease configuration tree manipulation. ### How to use it ```php class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder() { ... $rootNode ->children() ->arrayNode('social_media_channels') ->children() ->booleanNode('enable')->end() ->arrayNode('twitter')->end() ->arrayNode('facebook')->end() ->arrayNode('instagram')->end() ->end() ->end() ->end() ; $this->changeSocialMediaChannelConfiguration($rootNode->find('social_media_channels.enable')); $this->addTwitterConfiguration($rootNode->find('social_media_channels.twitter')); $this->addFacebookConfiguration($rootNode->find('social_media_channels.facebook')); $this->addInstagramConfiguration($rootNode->find('social_media_channels.instagram')); return $treeBuilder; } private function changeSocialMediaChannelConfiguration(NodeDefinition $node) { $node ->defaultTrue() ; } private function addTwitterConfiguration(NodeDefinition $node) { $node ->children() ->integerNode('client_id')->end() ->scalarNode('client_secret')->end() ->end() ; } private function addFacebookConfiguration(NodeDefinition $node) { $node ->children() ->integerNode('client_id')->end() ->scalarNode('client_secret')->end() ->end() ; } private function addInstagramConfiguration(NodeDefinition $node) { $node ->children() ->integerNode('client_id')->end() ->scalarNode('client_secret')->end() ->end() ; } } ``` Commits ------- e3b248a [Config] Introduce find method in ArrayNodeDefinition to ease configuration tree manipulation
This was referenced Nov 12, 2019
Merged
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.
Description
This PR introduces a new
find(string $nodePath)
method in theArrayNodeDefinition
class, which helps you finding the right node to prepend configuration to ease configuration tree manipulation.How to use it