1

I have a parent configuration specification

GenericDatabaseAdapterConfiguration implements ConfigurationInterface

It has some default values - host, user and password. Then there are children that have their specific configuration options.

MySQLDatabaseAdapterConfiguration extends GenericDatabaseAdapterConfiguration

It has charset option, that MSSQLDatabaseAdapterConfiguration does not have.

What would be a good way to alter the existing TreeBuilder that is returned from GenericDatabaseAdapterConfiguration::getConfigTreeBuilder(). Ideally I would like something like parent::getConfigTreeBuilder()->appendTo('parameters', $mssqlCustomSettingsNode);, but that does not exist.

So far I created extension points inside the Generic class. $this->append($this->getSshTunnelConnectionParametersNode()) is called inside the tree and empty method getSshTunnelConnectionParametersNode is inside the generic class that can be overridden in children. But that is not ideal as I need to anticipate every possible point of extension in the Generic class.

Is there a better way?

Tomáš Fejfar
  • 11,129
  • 8
  • 54
  • 82
  • For inspiration - completely different approach to config/param inheritance: https://www.tomasvotruba.cz/blog/2018/11/29/how-to-manage-configuration-in-symfony-without-bundle-extension-and-configuraiton I use it for all CLI applications in Symplify and 2 Symfony projects: https://github.com/tomasvotruba/open-project – Tomas Votruba Dec 04 '18 at 18:27
  • The question is unfortunately not at all connected to Symfony applications. We're using configuration from SF in a plain PHP projects... – Tomáš Fejfar Dec 05 '18 at 19:25
  • Wow, that's very creative. I'd love to see such an application and reasons behind it. – Tomas Votruba Dec 05 '18 at 22:36
  • 1
    It's Keboola components - miniature docker-wrapped data manipulation apps - based on https://github.com/keboola/php-component, implementation: https://github.com/keboola/http-extractor – Tomáš Fejfar Dec 06 '18 at 13:14
  • I see, thanks for links! – Tomas Votruba Dec 06 '18 at 14:37

0 Answers0