Generates service definitions for services.

@param array            $services  Services
@param ContainerBuilder $container Container builder
340311
private function generateServices(array $services, ContainerBuilder $container)
    {
        foreach ($services as $serviceName => $service) {
            $serviceId = 'bridge.'.$serviceName;

            $serviceDefinition = $this->createComponentDefinition($serviceName, $service['class'], $service['options']);
            $serviceDefinition->addMethodCall('setEventDispatcher', array(new Reference('bridge.event_dispatcher')));
            $serviceDefinition->addMethodCall('setRegistry', array(new Reference('bridge.registry')));

            $this->generateGroups($service['groups'], $serviceId, $serviceDefinition, $container);

            $container->setDefinition($serviceId, $serviceDefinition);

            $container
                ->getDefinition('bridge.registry')
                ->addMethodCall('addService', array(new Reference($serviceId)));
        }
    }
450614
public function process(ContainerBuilder $container)
    {
        $factory = $container->findDefinition(FilterFactory::class);

        $filters = [];

        foreach ($container->findTaggedServiceIds(self::FILTER_TAG) as $id => $attributes) {
            $filters[$id] = new Reference($id);
        }

        $factory->replaceArgument(0, ServiceLocatorTagPass::register($container, $filters));
    }
663406
public function process(ContainerBuilder $container)
    {
        foreach ($container->getDefinitions() as $definition) {
            $interfaces = class_implements($definition->getClass());
            foreach ($interfaces as $interface) {
                if (substr($interface, -14) === 'AwareInterface') {
                    $camelCasedServiceId = substr($interface, strrpos($interface, '\\') + 1, -14);
                    $serviceId = Container::underscore($camelCasedServiceId);

                    if ($container->has($serviceId)) {
                        $setterMethod = 'set'.$camelCasedServiceId;

                        $definition->addMethodCall($setterMethod, array(new Reference($serviceId)));
                    }
                }
            }
        }
    }
884972
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition(static::MANAGER_DEFINITION)) {
            return;
        }

        $manager = $container->getDefinition(static::MANAGER_DEFINITION);
        $services = $container->findTaggedServiceIds(static::SERVICE_TAG);

        foreach ($services as $id => $attributes) {
            if (! isset($attributes[0]['key']) || empty($attributes[0]['key'])) {
                throw new \InvalidArgumentException(
                    sprintf(
                        'Service "%s" must define the "key" attribute on "thelia.asset.filter" tag.',
                        $id
                    )
                );
            }

            $class = $container->getDefinition($id)->getClass();

            if (! is_subclass_of($class, '\Assetic\Filter\FilterInterface')) {
                throw new \InvalidArgumentException(
                    sprintf(
                        'Service "%s" should implement the \Assetic\Filter\FilterInterface interface',
                        $id
                    )
                );
            }

            $manager->addMethodCall(
                'registerAssetFilter',
                [ $attributes[0]['key'], new Reference($id) ]
            );
        }
    }
655002
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition($this->collectionServiceId)) {
            return;
        }

        $collection = $this->getCollection($container);

        foreach ($container->findTaggedServiceIds($this->serviceTag) as $id => $attributes) {
            $this->addServiceToCollection($collection, $id);
        }
    }
1141418
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition(TabRegistry::class)) {
            return;
        }

        $tabRegistry = $container->getDefinition(TabRegistry::class);
        $tabGroupDefinition = new Definition(TabGroup::class, ['systeminfo']);
        $tabRegistry->addMethodCall('addTabGroup', [$tabGroupDefinition]);
    }
178182
public function process(ContainerBuilder $container)
    {
        if (!$container->has($this->serviceId)) {
            return;
        }
        $definition = $container->findDefinition($this->serviceId);
        $handlers = array();
        $this->collectServiceIds(
            $container,
            $this->tag,
            $this->keyAttribute,
            function ($key, $serviceId, array $tagAttributes) use (&$handlers) {
                if (isset($tagAttributes['method'])) {
                    $callable = [$serviceId, $tagAttributes['method']];
                } else {
                    $callable = $serviceId;
                }
                $handlers[ltrim($key, '\\')] = $callable;
            }
        );
        $definition->replaceArgument(0, $handlers);
    }
731475
public function process(ContainerBuilder $container)
    {
        if ($container->hasDefinition('ucms_contrib.type_handler')) {
            $taggedServices = $container->findTaggedServiceIds('ucms_contrib.type_handler');

            foreach ($taggedServices as $id => $attributes) {
                $formatter = $container->getDefinition($id);

                $formatter->addMethodCall(
                    'setTypeHandler',
                    [new Reference('ucms_contrib.type_handler')]
                );
            }
        }

        if ($container->hasDefinition('ucms_site.manager')) {
            $taggedServices = $container->findTaggedServiceIds('ucms_site.manager');

            foreach ($taggedServices as $id => $attributes) {
                $definition = $container->getDefinition($id);

                $definition->addMethodCall(
                    'setSiteManager',
                    [new Reference('ucms_site.manager')]
                );
            }
        }
    }
1018360
private function createContainerDefinition(ContainerBuilder $container, ServiceConfig $serviceConfig)
    {
        $containerDefinition = new Definition($this->containerClass);

        #$definitionBase = new Definition($this->containerClass);
        #$container->addDefinitions(array($baseTag => $definitionBase));

        # $definitionBase = $container->getDefinition($baseTag);
        #$definitionBase->addMethodCall('addServiceId', array($tag, $serviceId));

        foreach ($this->findServiceIdsByTag($container, $serviceConfig) as $name => $serviceId) {
            $containerDefinition->addMethodCall(
                'offsetSet',
                array(
                    $name,
                    $this->getDefinitionForServiceId($serviceId, $serviceConfig)
                )
            );
        }

        return $containerDefinition;
    }
787392
public function process(ContainerBuilder $container)
    {
        if (!$container->has('support_tools.system_info.output_registry')) {
            return;
        }

        $outputFormattersTagged = $container->findTaggedServiceIds('support_tools.system_info.output_format');

        $outputFormatters = [];
        foreach ($outputFormattersTagged as $id => $tags) {
            foreach ($tags as $attributes) {
                $outputFormatters[$attributes['format']] = new Reference($id);
            }
        }

        $outputFormatRegistryDef = $container->findDefinition('support_tools.system_info.output_registry');
        $outputFormatRegistryDef->setArguments([$outputFormatters]);
    }
840055
private function registerService(ContainerBuilder $container, $serviceId, $serviceClass)
    {
        if (class_exists($serviceClass)) {
            $container->register($serviceId, $serviceClass);
        }
    }
1253675
protected function mapClassParameters(array $classes, ContainerBuilder $container)
    {
        foreach ($classes as $model => $serviceClasses) {
            foreach ($serviceClasses as $service => $class) {
                $container->setParameter(
                    sprintf(
                        'opifer_cms.%s_%s',
                        $model,
                        $service
                    ),
                    $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);
    }
206515
function build(Container $container)
    {
        if (! $container instanceof Container )
            throw new \Exception(sprintf(
                'Container must instanceof "ContainerManager", you given "%s".'
                , (is_object($container)) ? get_class($container) : gettype($container)
            ));

        // ORDER IS MANDATORY

        // Namespace:
        $this->_buildNamespace($container);

        // Interfaces:
        $this->_buildImplementation($container);

        // Initializer:
        // maybe used while Creating Services
        $this->_buildInitializer($container);

        // Nested:
        $this->_buildNested($container);

        // Aliases:
        $this->_buildExtend($container);

        // Service:
        $this->_buildService($container);
    }
29514
public function process(ContainerBuilder $container)
    {
        if (!$container->has($this->callableServiceId)) {
            return;
        }

        if (!$container->has($this->serviceLocatorId)) {
            return;
        }

        $callableDefinition = $container->findDefinition($this->callableServiceId);
        $serviceLocatorDefinition = $container->findDefinition($this->serviceLocatorId);

        $handlers = array();
        $services = array();

        $this->collectServiceIds(
            $container,
            $this->tag,
            $this->keyAttribute,
            function ($key, $serviceId, array $tagAttributes) use (&$handlers, &$services) {
                if (isset($tagAttributes['method'])) {
                    // Symfony 3.3 supports services by classname. This interferes with `is_callable`
                    // in `ServiceLocatorAwareCallableResolver`
                    $callable = [
                        'serviceId' => $serviceId,
                        'method'    => $tagAttributes['method'],
                    ];
                } else {
                    $callable = $serviceId;
                }

                $handlers[ltrim($key, '\\')][] = $callable;
                $services[$serviceId] = new Reference($serviceId);
            }
        );

        $callableDefinition->replaceArgument(0, $handlers);
        $serviceLocatorDefinition->replaceArgument(0, $services);
    }
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));
            }
        }
    }
777066
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition($this->subjectService)) {
            return;
        }

        $subjects = $this->findTaggedServices($container, $this->subjectTag, SubjectInterface::class, 'support', false);

        $subjectDefinition = $container->getDefinition($this->subjectService);
        $subjectDefinition->replaceArgument(0, $subjects);
    }