private function loadTypePagerProvider(array $typeConfig, ContainerBuilder $container, $indexName, $typeName)
    {
        if (isset($typeConfig['provider']['service'])) {
            return $typeConfig['provider']['service'];
        }

        $baseConfig = $typeConfig['provider'];
        unset($baseConfig['service']);

        $driver = $typeConfig['driver'];

        switch ($driver) {
            case 'orm':
                $providerDef = new ChildDefinition('fos_elastica.pager_provider.prototype.'.$driver);
                $providerDef->replaceArgument(2, $typeConfig['model']);
                $providerDef->replaceArgument(3, $baseConfig);

                break;
            case 'mongodb':
                $providerDef = new ChildDefinition('fos_elastica.pager_provider.prototype.'.$driver);
                $providerDef->replaceArgument(2, $typeConfig['model']);
                $providerDef->replaceArgument(3, $baseConfig);

                break;
            case 'phpcr':
                $providerDef = new ChildDefinition('fos_elastica.pager_provider.prototype.'.$driver);
                $providerDef->replaceArgument(2, $typeConfig['model']);
                $providerDef->replaceArgument(3, $baseConfig);

                break;
            default:
                throw new \LogicException(sprintf('The pager provider for driver "%s" does not exist.', $driver));
        }

        /* Note: provider services may conflict with "prototype.driver", if the
         * index and type names were "prototype" and a driver, respectively.
         */
        $providerId = sprintf('fos_elastica.pager_provider.%s.%s', $indexName, $typeName);
        $providerDef->addTag('fos_elastica.pager_provider', ['index' => $indexName, 'type' => $typeName]);

        $container->setDefinition($providerId, $providerDef);

        return $providerId;
    }