craue / CraueConfigBundle

Database-stored settings made available via a service for your Symfony project.
MIT License
173 stars 35 forks source link

Replacing Setter Injection with Constructor Injection #13

Closed afurculita closed 10 years ago

afurculita commented 10 years ago

A Constructor injection is better for Config and ConfigTemplateExtension classes, because they can't operate without the injected arguments. In this case a Setter injection will be an anti-pattern, because the class is not fully initialized and the setters will have to finish the initialization.

craue commented 10 years ago

I still generally favor setter injection to use classes in a more flexible way, e.g. for tests. :smirk: But I'm fine with adding constructors while keeping the setters (unless there's a good reason not to keep them). And the tests should pass...

craue commented 10 years ago

Are you still working on this?