Skip to content

[Twig Component] How to determine if a component is installed from within a bundle #2098

Closed Answered by tacman
tacman asked this question in Questions & Answers
Discussion options

You must be logged in to vote

I figured it out. In the bundle...

    public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
    {
        // get all bundles
        $bundles = $builder->getParameter('kernel.bundles');
        $hasSimpleDatatables = in_array(SurvosSimpleDatatablesBundle::class, array_values($bundles));

It is somewhat confusing that the Container is sometimes called $container and other times called $builder, depending on the context:

// src/Acme/HelloBundle/DependencyInjection/AcmeHelloExtension.php
public function prepend(ContainerBuilder $container): void
{
    // get all bundles
    $bundles = $container->getParameter('kernel.bundles');
    //…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tacman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant