Skip to content
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

Using the getConfiguration method in the LiipMonitorExtension class #247

Merged
merged 1 commit into from Nov 1, 2020

Conversation

voodooism
Copy link
Contributor

It would be great to have an opportunity to extend the LiipMonitorExtension class and add some new configuration.

Unfortunately, there is only one way to extend the configuration of this bundle now. To achieve it we have to completely override the Liip\MonitorBundle\DependencyInjection\LiipMonitorExtension::load method.

Let's suppose that I want to add some new features to the bundle. I have My\DependencyInjection\Configuration like this:

class Configuration implements ConfigurationInterface
{
    public function getConfigTreeBuilder(): TreeBuilder
    {
        $liipConfiguration = new LiipConfiguration();

        $liipTreeBuilder = $liipConfiguration->getConfigTreeBuilder();

        $liipTreeBuilder->getRootNode()
            ->children()
                ->scalarNode('my_config_parameter')->cannotBeEmpty()->end()
            ->end();

        return $liipTreeBuilder;
    }
}

The next step is to add this new config parameter to Extension. I would do something like that:

class MyExtension extends LiipMonitorExtension
{
    public function load(array $configs, ContainerBuilder $container): void
    {
        parent::load($configs, $container);
        //my own logic here
    }

    public function getConfiguration(array $config, ContainerBuilder $container)
    {
        return new My\DependencyInjection\Configuration();
    }
}

But, unfortunately, it does not work, because the Liip\MonitorBundle\DependencyInjection\Configuration is instantiated explicitly in the Liip\MonitorBundle\DependencyInjection\LiipMonitorExtension::load method.

@voodooism voodooism changed the title Usint the getConfiguration method in the LiipMonitorExtension class Using the getConfiguration method in the LiipMonitorExtension class Oct 30, 2020
@kbond kbond merged commit c73da20 into liip:master Nov 1, 2020
@kbond
Copy link
Collaborator

kbond commented Nov 1, 2020

Thanks @voodooism

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants