Reputation: 583
I have been coding in SYmfony since last 6 months now. And after completing a couple of projects, I started exploring symfony in greater details. While exploring i came accross, TreeBuilder component. Now, i understood the concept TreeBuilder very well. Its basically used to dump config files in YML. But, the question is, why would one use TreeBUilder when you can directly modify the condig yml files.? Is there any other better use case where one should use TreeBUilder specificaly.? Could you please help me understand any use case. This will give me a better understanding.
Upvotes: 3
Views: 301
Reputation: 10890
According to documentation Tree builder
is a component which can/should be used to validate configuration provided by end user.
Configuration values are usually expected to show some kind of hierarchy. Also, values should be of a certain type, be restricted in number or be one of a given set of values. For example, the following configuration (in YAML) shows a clear hierarchy and some validation rules that should be applied to it (like: "the value for auto_connect must be a boolean value")
So basically you can make a set of requirements to configuration of your bundle like
For complete reference check documentation
Upvotes: 2