src/DependencyInjection/Compiler/RegisterPagerPersistersPass.php
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition('fos_elastica.pager_persister_registry')) {
            return;
        }

        $registry = $container->getDefinition('fos_elastica.pager_persister_registry');

        $nameToServiceIdMap = [];
        foreach ($container->findTaggedServiceIds('fos_elastica.pager_persister', true) as $id => $attributes) {
            foreach ($attributes as $attribute) {
                if (!isset($attribute['persisterName'])) {
                    throw new \InvalidArgumentException(sprintf('Elastica pager persister "%s" must specify the "persisterName" attribute.', $id));
                }

                $persisterName = $attribute['persisterName'];

                if (isset($nameToServiceIdMap[$persisterName])) {
                    throw new \InvalidArgumentException(sprintf(
                        'Cannot register pager persister "%s". The pager persister "%s" has been registered for same name "%s"',
                        $id,
                        $nameToServiceIdMap[$persisterName],
                        $persisterName
                    ));
                }

                $persisterDef = $container->getDefinition($id);
                if (!$persisterDef->getFactory() && $persisterDef->getClass()) {
                    // You are on your own if you use a factory to create a persister.
                    // It would fail in runtime if the factory does not return a proper persister.
                    $this->assertClassImplementsPagerPersisterInterface($id, $container->getParameterBag()->resolveValue($persisterDef->getClass()));
                }

                if (!$persisterDef->isPublic()) {
                    throw new \InvalidArgumentException(sprintf('Elastica pager persister "%s" must be a public service', $id));
                }

                $nameToServiceIdMap[$persisterName] = $id;
            }
        }

        $registry->replaceArgument(0, $nameToServiceIdMap);
    }
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition('fos_elastica.pager_persister_registry')) {
            return;
        }

        $registry = $container->getDefinition('fos_elastica.pager_persister_registry');

        $nameToServiceIdMap = [];
        foreach ($container->findTaggedServiceIds('fos_elastica.pager_persister', true) as $id => $attributes) {
            foreach ($attributes as $attribute) {
                if (!isset($attribute['persisterName'])) {
                    throw new \InvalidArgumentException(sprintf('Elastica pager persister "%s" must specify the "persisterName" attribute.', $id));
                }

                $persisterName = $attribute['persisterName'];

                if (isset($nameToServiceIdMap[$persisterName])) {
                    throw new \InvalidArgumentException(sprintf(
                        'Cannot register pager persister "%s". The pager persister "%s" has been registered for same name "%s"',
                        $id,
                        $nameToServiceIdMap[$persisterName],
                        $persisterName
                    ));
                }

                $persisterDef = $container->getDefinition($id);
                if (!$persisterDef->getFactory() && $persisterDef->getClass()) {
                    // You are on your own if you use a factory to create a persister.
                    // It would fail in runtime if the factory does not return a proper persister.
                    $this->assertClassImplementsPagerPersisterInterface($id, $container->getParameterBag()->resolveValue($persisterDef->getClass()));
                }

                if (!$persisterDef->isPublic()) {
                    throw new \InvalidArgumentException(sprintf('Elastica pager persister "%s" must be a public service', $id));
                }

                $nameToServiceIdMap[$persisterName] = $id;
            }
        }

        $registry->replaceArgument(0, $nameToServiceIdMap);
    }
{@inheritdoc}