Plugin dependencies
Spomky opened this issue · 3 comments
Spomky commented
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?
matthiasnoback commented
There's currently no way to accomplish this I guess. What's your exact use case?
magarzon commented
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.