Processes the ContainerBuilder to remove unused definitions.

@param ContainerBuilder $container
766027
public function process(ContainerBuilder $container)
    {
        $compiler = $container->getCompiler();
        $formatter = $compiler->getLoggingFormatter();
        $graph = $compiler->getServiceReferenceGraph();

        $hasChanged = false;
        foreach ($container->getDefinitions() as $id => $definition) {
            if ($definition->isPublic()) {
                continue;
            }

            if ($graph->hasNode($id)) {
                $edges = $graph->getNode($id)->getInEdges();
                $referencingAliases = array();
                $sourceIds = array();
                foreach ($edges as $edge) {
                    $node = $edge->getSourceNode();
                    $sourceIds[] = $node->getId();

                    if ($node->isAlias()) {
                        $referencingAliases[] = $node->getValue();
                    }
                }
                $isReferenced = (count(array_unique($sourceIds)) - count($referencingAliases)) > 0;
            } else {
                $referencingAliases = array();
                $isReferenced = false;
            }

            if (1 === count($referencingAliases) && false === $isReferenced) {
                $container->setDefinition((string) reset($referencingAliases), $definition);
                $definition->setPublic(true);
                $container->removeDefinition($id);
                $compiler->addLogMessage($formatter->formatRemoveService($this, $id, 'replaces alias '.reset($referencingAliases)));
            } elseif (0 === count($referencingAliases) && false === $isReferenced) {
                $container->removeDefinition($id);
                $container->resolveEnvPlaceholders(serialize($definition));
                $compiler->addLogMessage($formatter->formatRemoveService($this, $id, 'unused'));
                $hasChanged = true;
            }
        }

        if ($hasChanged) {
            $this->repeatedPass->setRepeat();
        }
    }
283090
public function process(ContainerBuilder $container): void
    {
        if ($container->has('ezpublish.image_alias.imagine.cache_resolver')) {
            $container
                ->findDefinition('ezpublish.image_alias.imagine.cache_resolver')
                ->setClass(IORepositoryResolver::class);
        }
    }
33750
public function process(ContainerBuilder $container)
    {
        $this->container = $container;
        $this->graph = $container->getCompiler()->getServiceReferenceGraph();
        $this->graph->clear();
        $this->lazy = false;

        foreach ($container->getAliases() as $id => $alias) {
            $targetId = $this->getDefinitionId((string) $alias);
            $this->graph->connect($id, $alias, $targetId, $this->getDefinition($targetId), null);
        }

        parent::process($container);
    }
107629
public function process(ContainerBuilder $container): void
    {
        if (!$container->has('ngsite.menu.factory.location')) {
            return;
        }

        $factory = $container->findDefinition('ngsite.menu.factory.location');

        $extensions = [];

        foreach ($container->findTaggedServiceIds('ngsite.menu.factory.location.extension') as $extension => $tags) {
            foreach ($tags as $tag) {
                $priority = (int) ($tag[0]['priority'] ?? 0);
                $extensions[$priority][] = new Reference($extension);
            }
        }

        krsort($extensions);
        $extensions = array_merge(...$extensions);

        $factory->replaceArgument(2, $extensions);
    }
681391
public function process(ContainerBuilder $container)
    {
        $this->container = $container;
        foreach ($container->getDefinitions() as $definition) {
            if ($definition->isSynthetic() || $definition->isAbstract()) {
                continue;
            }

            $definition->setArguments(
                $this->processArguments($definition->getArguments())
            );

            $calls = array();
            foreach ($definition->getMethodCalls() as $call) {
                try {
                    $calls[] = array($call[0], $this->processArguments($call[1], true));
                } catch (RuntimeException $e) {
                    // this call is simply removed
                }
            }
            $definition->setMethodCalls($calls);

            $properties = array();
            foreach ($definition->getProperties() as $name => $value) {
                try {
                    $value = $this->processArguments(array($value), true);
                    $properties[$name] = reset($value);
                } catch (RuntimeException $e) {
                    // ignore property
                }
            }
            $definition->setProperties($properties);
        }
    }
680361
public function process(ContainerBuilder $container)
    {
        foreach ($container->getDefinitions() as $id => $definition) {
            if ($definition->isAbstract()) {
                $container->removeDefinition($id);
                $container->log($this, sprintf('Removed service "%s"; reason: abstract.', $id));
            }
        }
    }
147525
public function process(ContainerBuilder $container)
    {
        $repository = $container->getDefinition(HandlerRepository::class);
        $finder = new BundleNameFinder($container->getParameter('kernel.bundles'));

        $locatableServices = [];

        foreach ($container->findTaggedServiceIds(self::HANDLER_TAG) as $id => $attributes) {
            $repository->addMethodCall('addBundleName', [
                $id,
                $finder->find($container->getDefinition($id)->getClass()),
            ]);

            $locatableServices[$id] = new Reference($id);
        }

        $repository->replaceArgument(0, ServiceLocatorTagPass::register($container, $locatableServices));
    }
1321566
public function process(ContainerBuilder $container)
    {
        $this->container = $container;
        $this->graph = $container->getCompiler()->getServiceReferenceGraph();
        $this->graph->clear();

        foreach ($container->getDefinitions() as $id => $definition) {
            if ($definition->isSynthetic() || $definition->isAbstract()) {
                continue;
            }

            $this->currentId = $id;
            $this->currentDefinition = $definition;

            $this->processArguments($definition->getArguments());
            if (is_array($definition->getFactory())) {
                $this->processArguments($definition->getFactory());
            }

            if (!$this->onlyConstructorArguments) {
                $this->processArguments($definition->getMethodCalls());
                $this->processArguments($definition->getProperties());
                if ($definition->getConfigurator()) {
                    $this->processArguments(array($definition->getConfigurator()));
                }
            }
        }

        foreach ($container->getAliases() as $id => $alias) {
            $this->graph->connect($id, $alias, (string) $alias, $this->getDefinition((string) $alias), null);
        }
    }
698083
public function process(ContainerBuilder $container)
    {
        do {
            $this->repeat = false;
            foreach ($this->passes as $pass) {
                $pass->process($container);
            }
        } while ($this->repeat);
    }
74221
public function process(ContainerBuilder $container)
    {
        $swagger = $container->getDefinition("draw.swagger");

        foreach (array_keys($container->findTaggedServiceIds("swagger.extractor")) as $id) {
            if ($container->getDefinition($id)->isAbstract()) {
                continue;
            }

            $swagger->addMethodCall("registerExtractor", array(new Reference($id)));
        }

        foreach ($container->getDefinitions() as $id => $definition) {
            if (!$definition instanceof DefinitionDecorator) {
                continue;
            }

            if ($definition->getParent() != "draw.swagger.extractor.constraint_extractor") {
                continue;
            }

            $swagger->addMethodCall("registerExtractor", array(new Reference($id)));
        }
    }
215925
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition('lag.repository.repository_pool')) {
            return;
        }
        // find service with doctrine.repository tag
        $repositoryTags = $container->findTaggedServiceIds('doctrine.repository');
        // get pool definition
        $poolDefinition = $container->findDefinition('lag.repository.repository_pool');

        foreach ($repositoryTags as $serviceId => $tags) {
            // add repository to the pool
            $poolDefinition->addMethodCall('add', [
                new Reference($serviceId),
            ]);
        }
    }
1004935
public function process(ContainerBuilder $container)
    {
        $this->buildApple($container);
        $this->buildAndroid($container);
        $this->buildWindows($container);
    }
511257
public function process(ContainerBuilder $container): void
    {
        if (true === self::enabled($container))
        {
            $excludedFiles = canonicalizeFilesPath(self::getExcludedFiles($container));

            $files = searchFiles(self::getDirectories($container), '/\.php/i');

            $this->registerClasses($container, $files, $excludedFiles);
        }
    }
739713
public function process(ContainerBuilder $container)
    {
        $this->setFactoryAndServerClasses($container);
        parent::process($container);
        $this->setCasServerConfig($container);
    }
14660
public function process(ContainerBuilder $container)
    {
        $this->setServiceAlias( $container, HeliopsisEzFormsExtension::FACADE_SERVICE_ID );
        $this->setServiceAlias( $container, HeliopsisEzFormsExtension::FORM_PROVIDER_SERVICE_ID );
        $this->setServiceAlias( $container, HeliopsisEzFormsExtension::HANDLER_PROVIDER_SERVICE_ID );
        $this->setServiceAlias( $container, HeliopsisEzFormsExtension::RESPONSE_PROVIDER_SERVICE_ID );
    }
942645
public function process(ContainerBuilder $container)
    {
        if ($container->hasDefinition('umenu.manager') || $container->hasAlias('umenu.manager')) {
            $eventListener = $container->getDefinition('ucms_tree.site_event_subscriber');

            $eventListener->addMethodCall(
                'setTreeManager',
                [new Reference('umenu.manager')]
            );
        }
    }
46718
public function process(ContainerBuilder $container)
    {
        $fileSytem = new Filesystem(new Local(realpath($container->getParameter('kernel.root_dir') . "/../var")));
        $fileSytem->createDir('expansion');
        $fileSytem = new Filesystem(new Local(realpath($container->getParameter('kernel.root_dir') . "/../var/expansion")));

        $this->fetchDataFromRemote($fileSytem, $container);

        if ($fileSytem->has(self::MAPPINGS_FILE)) {
            $data = json_decode($fileSytem->read(self::MAPPINGS_FILE), true);
            if ($data) {
                $values = [];
                foreach ($data as $titleId => $titleInformation) {
                    $values[$titleId] = $titleInformation['game'];
                }

                $container->setParameter("expansion.storage.gamedata.titles", $values);
            }
        }
    }