I'm developing a bundle who has a dependency on another one.
In order to handle the case that the base bundle has not been installed I'll like to perform a "bundle_exists()" function inside a controller.
The question is: How can I have a list of installed bundles or How can I check for the name (eventually also the version) of a bundle.
Thanks.
Your class needs to have access to the container object (either by extending or DI).
Then you can do;
$this->container->getParameter('kernel.bundles');
This will give you a list of bundles installed.
Update;
If you are in a controller that extends the Symfony\Bundle\FrameworkBundle\Controller\Controller
or in a command class that extends Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
, you can just get the parameter.
$this->getParameter('kernel.bundles')
.
Else @Wouter J's answer is your best answer.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments