public function configureProviderPlugins(ContainerBuilder $container, array $config, string $providerServiceId): array
    {
        $plugins = [];
        foreach ($config['plugins'] as $plugin) {
            if ($plugin['reference']['enabled']) {
                $plugins[] = $plugin['reference']['id'];
            }
        }

        if (isset($config['cache']) || isset($config['cache_lifetime']) || isset($config['cache_precision'])) {
            if (null === $cacheServiceId = $config['cache']) {
                if (!$container->has('app.cache')) {
                    throw new \LogicException('You need to specify a service for cache.');
                }
                $cacheServiceId = 'app.cache';
            }
            $plugins[] = $providerServiceId.'.cache';
            $container->register($providerServiceId.'.cache', CachePlugin::class)
                ->setPublic(false)
                ->setArguments([new Reference($cacheServiceId), (int) $config['cache_lifetime'], $config['cache_precision']]);
        }

        if (isset($config['limit'])) {
            $plugins[] = $providerServiceId.'.limit';
            $container->register($providerServiceId.'.limit', LimitPlugin::class)
                ->setPublic(false)
                ->setArguments([(int) $config['limit']]);
        }

        if (isset($config['locale'])) {
            $plugins[] = $providerServiceId.'.locale';
            $container->register($providerServiceId.'.locale', LocalePlugin::class)
                ->setPublic(false)
                ->setArguments([$config['locale']]);
        }

        if (isset($config['logger'])) {
            $plugins[] = $providerServiceId.'.logger';
            $container->register($providerServiceId.'.logger', LoggerPlugin::class)
                ->setPublic(false)
                ->setArguments([new Reference($config['logger'])]);
        }

        if ($container->has(FakeIpPlugin::class)) {
            $plugins[] = FakeIpPlugin::class;
        }

        if ($container->has(GeocoderDataCollector::class)) {
            $plugins[] = $providerServiceId.'.profiler';
            $container->register($providerServiceId.'.profiler', ProfilingPlugin::class)
                ->setPublic(false)
                ->setArguments([substr($providerServiceId, strlen('bazinga_geocoder.provider.'))])
                ->addTag('bazinga_geocoder.profiling_plugin');
        }

        return array_map(function (string $id) {
            return new Reference($id);
        }, $plugins);
    }