matthiasnoback/symfony-bundle-plugins

Plugin dependencies

Spomky opened this issue · 3 comments

Hi,

Is there a way for a plugin to verify other plugins are enable?

For example, plugin A needs plugins B and C.
Plugin A want to verify that plugins B and C are correctly loaded by this bundle.

I do not know how to do this check (I cannot figure out how to get the list of the loaded plugins).
Any idea?

There's currently no way to accomplish this I guess. What's your exact use case?

Hi.

I've resolved something similar in this way, I don't know if this solution fits your needs:

I have a "core" plugin with the prepend method implemented. In that method I have this:

public function prepend(ContainerBuilder $container)
{
        $config = $container->getExtensionConfig('my_bundle_alias');

        if (!empty($config)) {
            $config = array_shift($config);
        }

        foreach($config as $key=>$plugin) {
             ......
        }
}

And in the config.yml file I have this:

my_bundle_alias:
      plugin1_configuration:
           ...
      plugin2_configuration:
          ...

But as you can see, you need to explicitly add or remove the configuration for the plugins you have enabled.

Thanks @magarzon your solution is a good solution to verify a plugin is loaded.