protected function addProvider(ContainerBuilder $container, $dir, $bundle)
    {
        if ($container->hasDefinition('integrated_solr.converter.config.provider.file.' . $bundle)) {
            return null;
        }

        // If the bundle got a config/solr directory then a provider is created for this bundle. This
        // however still does not mean that the bundle actually got any solr config files but that is
        // not really a problem.

        if (!is_dir($dir . '/Resources/config/solr')) {
            return null;
        }

        $definition = new Definition(XmlProvider::class);
        $definition->setPublic(false);
        $definition->setArguments([$this->addFinder($container, $dir . '/Resources/config/solr', $bundle)]);

        $container->setDefinition('integrated_solr.converter.config.provider.file.' . $bundle, $definition);

        return new Reference('integrated_solr.converter.config.provider.file.' . $bundle);
    }