Closed dmolineus closed 8 years ago
Optional dependencies can be solved by checking for the existence of a bundle in your code. Either using class_exists
or probably using in_array('…', $kernel->getBundles())
.
I think that's sufficient?
So you suggest using class_exists('Contao\\NewsBundle\ContaoNewsBundle')
in the plugin. Well, simple solution. Didn't come in my mind.
The kernel is not passed to the plugin as dependency so it's not available there. Maybe it could be passed as argument to the plugin constructors. If you don't think it's neccesary just close this ticket.
well actually it does not make sense to pass the kernel, because it's the bundle loading process so there's information to get. yes, a simple class_exists
should do for now :-)
I had a brief look to the manager bundle. As far I can see there is no support for optional bundle dependencies in the load after definition.
A use case first that could be an extension which would modify the calendar and news bundle but does not require that both are installed.