Process main configuration for this connection.

@param array $serviceConnArguments
@param array $resolvedConnConfig
171225
private function processMainConfiguration(array &$serviceConnArguments, $resolvedConnConfig)
    {
        if (array_key_exists('master', $serviceConnArguments)) {
            $this->replaceConnectionArguments($serviceConnArguments['master'], $resolvedConnConfig);
        } elseif (array_key_exists('global', $serviceConnArguments)) {
            $this->replaceConnectionArguments($serviceConnArguments['global'], $resolvedConnConfig);
        } else {
            $this->replaceConnectionArguments($serviceConnArguments, $resolvedConnConfig);
        }
    }
79438
public function buildMessagingSystemFromConfiguration(ReferenceSearchService $referenceSearchService): ConfiguredMessagingSystem
    {
        foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
            if (!array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->channelBuilders)) {
                if (array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->defaultChannelBuilders)) {
                    $this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = $this->defaultChannelBuilders[$messageHandlerBuilder->getInputMessageChannelName()];
                } else {
                    $this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = SimpleMessageChannelBuilder::createDirectMessageChannel($messageHandlerBuilder->getInputMessageChannelName());
                }
            }
        }


        $interfaceToCallRegistry = InterfaceToCallRegistry::createWithInterfaces($this->interfacesToCall);
        $converters = [];
        foreach ($this->converterBuilders as $converterBuilder) {
            $converters[] = $converterBuilder->build($referenceSearchService);
        }
        $referenceSearchService = InMemoryReferenceSearchService::createWithReferenceService($referenceSearchService, [
            ConversionService::REFERENCE_NAME => AutoCollectionConversionService::createWith($converters),
            InterfaceToCallRegistry::REFERENCE_NAME => $interfaceToCallRegistry
        ]);

        $channelResolver = $this->createChannelResolver($referenceSearchService);
        $this->configureInterceptors($interfaceToCallRegistry);

        /** @var GatewayBuilder[][] $preparedGateways */
        $preparedGateways = [];
        foreach ($this->gatewayBuilders as $gatewayBuilder) {
            $preparedGateways[$gatewayBuilder->getReferenceName()][] = $gatewayBuilder;
        }
        $gateways = $this->configureGateways($preparedGateways, $referenceSearchService, $channelResolver);

        $consumerEndpointFactory = new ConsumerEndpointFactory($channelResolver, $referenceSearchService, $this->consumerFactories, $this->pollingMetadata);
        $consumers = [];

        foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
            $consumers[] = $consumerEndpointFactory->createForMessageHandler($messageHandlerBuilder);
        }

        foreach ($this->channelAdapters as $channelAdapter) {
            $consumers[] = $channelAdapter->build($channelResolver, $referenceSearchService, array_key_exists($channelAdapter->getEndpointId(), $this->pollingMetadata) ? $this->pollingMetadata[$channelAdapter->getEndpointId()] : null);
        }

        return MessagingSystem::create($consumers, $gateways, $channelResolver);
    }
781748
public function setConfiguration( models\Connection\Config $connectionConfig){
        $rest = $this->getService( self::API_CONNECTION_CONFIG);
        $rest->PUT( $connectionConfig);

        return $rest->getResult( models\Connection\Config::class);
    }
1134730
public function buildService(Container $container, ArrayResolver $serviceConfig, $serviceName)
    {
        return $this->serviceBuilder->buildService($container, $serviceConfig, $serviceName);
    }
552557
public function loadWriteRoutes($service, $resource, $serviceConfig)
    {
        $actionPost = ActionUtils::getRoutePost($service, $serviceConfig);
        $this->routes->add($resource . '.post', $actionPost);

        $actionPut = ActionUtils::getRoutePut($service, $serviceConfig);
        $this->routes->add($resource . '.put', $actionPut);

        $actionPostNoSlash = ActionUtils::getRoutePost($service, $serviceConfig);
        $actionPostNoSlash->setPath(substr($actionPostNoSlash->getPath(), 0, -1));
        $this->routes->add($resource . '.postNoSlash', $actionPostNoSlash);

        $actionPatch = ActionUtils::getRoutePatch($service, $serviceConfig);
        $this->routes->add($resource . '.patch', $actionPatch);

        $actionDelete = ActionUtils::getRouteDelete($service, $serviceConfig);
        $this->routes->add($resource . '.delete', $actionDelete);
    }
208070
protected function loadDefaultResolverServices($config, LoaderInterface $loader)
    {
        if ('xiidea.easy_audit.default_event_resolver' === $config['resolver']) {
            $loader->load('default/event-resolver.yml');
        }

        if (true === $config['default_logger']) {
            $loader->load('default/logger.yml');
        }

        if (false !== $config['doctrine_objects'] && 'xiidea.easy_audit.default_doctrine_event_resolver' === $config['doctrine_event_resolver']) {
            $loader->load('default/doctrine-event-resolver.yml');
        }
    }
210031
protected function findServiceIds(array $config, array &$serviceIds)
    {
        foreach ($config as $name => $value) {
            if (is_array($value)) {
                $this->findServiceIds($value, $serviceIds);
            } elseif ($name === 'service_id') {
                $serviceIds[] = $value;
            }
        }
    }
581601
public function registerService(Service\Serviceable $service, Service\Configurable $config)
    {
        $service->register($this->container, $config);
    }
177907
private function registerServices(ContainerBuilder $container, $config)
    {
        if ($config['annotation']['enabled']) {
            $this->verifyDoctrineBridgeExists('annotation');
            $container->register('cache.service.annotation', DoctrineCacheBridge::class)
                ->setFactory([DoctrineBridgeFactory::class, 'get'])
                ->addArgument(new Reference($config['annotation']['service_id']))
                ->addArgument($config['annotation'])
                ->addArgument(['annotation']);
        }

        if ($config['serializer']['enabled']) {
            $this->verifyDoctrineBridgeExists('serializer');
            $container->register('cache.service.serializer', DoctrineCacheBridge::class)
                ->setFactory([DoctrineBridgeFactory::class, 'get'])
                ->addArgument(new Reference($config['serializer']['service_id']))
                ->addArgument($config['serializer'])
                ->addArgument(['serializer']);
        }

        if ($config['validation']['enabled']) {
            $container->register('cache.service.validation', SymfonyValidatorBridge::class)
                ->setFactory([ValidationFactory::class, 'get'])
                ->addArgument(new Reference($config['validation']['service_id']))
                ->addArgument($config['validation']);
        }

        if ($config['session']['enabled']) {
            $container->register('cache.service.session', Psr6SessionHandler::class)
                ->setFactory([SessionHandlerFactory::class, 'get'])
                ->addArgument(new Reference($config['session']['service_id']))
                ->addArgument($config['session']);
        }

        if ($config['router']['enabled']) {
            $container->register('cache.service.router', CachingRouter::class)
                ->setFactory([RouterFactory::class, 'get'])
                ->setDecoratedService('router', null, 10)
                ->addArgument(new Reference($config['router']['service_id']))
                ->addArgument(new Reference('cache.service.router.inner'))
                ->addArgument($config['router']);
        }
    }
1370348
private function processObjectManagerConfigurations(array $configs, ContainerBuilder $container, LoaderInterface $loader, array &$loaded, $doctrineSubscriberTag)
    {
        $usedManagers = array();

        $listenerPriorities = array(
            'translatable' => -10,
            'loggable' => 5,
            'uploadable' => -5,
        );

        foreach ($configs as $name => $listeners) {
            foreach ($listeners as $ext => $enabled) {
                if (!$enabled) {
                    continue;
                }

                if (!isset($loaded[$ext])) {
                    $loader->load($ext.'.xml');
                    $loaded[$ext] = true;
                }

                $attributes = array('connection' => $name);

                if (isset($listenerPriorities[$ext])) {
                    $attributes['priority'] = $listenerPriorities[$ext];
                }

                $definition = $container->getDefinition(sprintf('stof_doctrine_extensions.listener.%s', $ext));
                $definition->addTag($doctrineSubscriberTag, $attributes);

                $usedManagers[$name] = true;
            }
        }

        return array_keys($usedManagers);
    }
1327860
protected function setUpSpecificConfigurations(Configuration $config)
    {
        if ($this->getLuceneHandlerName() !== null) {
            $config->setLuceneHandlerName($this->getLuceneHandlerName());
        }
    }
233700
public static function init($config = null)
    {
        self::registerDevelopmentErrorHandler();
        self::registerExceptionHandler();

        if ($config === null) {
            $config = static::loadAppConfig();
        }

        static::addCoreModule($config);

        $serviceConfig = isset($config['service_manager']) ? $config['service_manager'] : array();
        $listeners = isset($config['listeners'])? $config['listeners'] : array();
        $serviceManager = new ServiceManager(new ServiceConfig($serviceConfig));

        $serviceManager->setService('ApplicationConfig', $config);
        $serviceManager->get('ModuleManager')->loadModules();

        return $serviceManager->get('Application')->bootstrap($listeners);
    }
231810
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var $processingConfig ProcessingConfig */
        $processingConfig = $serviceLocator->get('processing_config');

        return ProcessingNode::initializeAs(NodeName::fromString($processingConfig->getNodeName()));
    }
580273
protected function processArguments($args) {
		if (is_array($args)) {
			foreach ($args as &$arg) {
				$arg = $this->processArguments($arg);
			}
			unset($arg);
			
			return $args;
		}
		
		if (is_string($args)) {
			if (preg_match('~^\[\[([a-z0-9_]+)\]\]$~i', $args, $matches)) {
				return new ServiceReference($this, $matches[1]);
			}
			
			if (preg_match('~^\{\{([a-z0-9_]+)\}\}$~i', $args, $matches)) {
				return new ConfigReference($this->getParametersConfig(), $matches[1]);
			}
		}
		
		return $args;
	}
52653
private function resolveArguments(ReflectionClass $reflection, array $arguments, array $resolvers)
    {
        $newArguments = $arguments;

        foreach ($resolvers as $resolver) {
            $newArguments = $resolver->resolveArguments($reflection, $newArguments);
        }

        if (!$reflection->hasMethod('__construct')) {
            return $newArguments;
        }

        $constructor = $reflection->getConstructor();
        $newArguments = $this->argumentOrganiser->organiseArguments($constructor, $newArguments);
        $this->validator->validateArguments($constructor, $newArguments);

        return $newArguments;
    }
338969
public function resolveBranchConfig(array $branchConfig)
    {
        $resolver = new OptionsResolver();
        $resolver
            ->setDefaults(array(
                'path' => null,
                'commands' => array(),
                'options' => array(),
            ))
            ->setAllowedTypes('commands', 'array')
            ->setAllowedTypes('options', 'array')
            ->setAllowedTypes('path', array('string', 'null'))
        ;

        try {
            return $resolver->resolve($branchConfig);
        } catch (InvalidArgumentException $exception) {
            $this->logger->critical('Couldn\'t resolve branch config: '.$exception->getTraceAsString());
            throw $exception;
        }
    }
141452
protected function processServices(array $config, Container $container, $alias = "")
    {
        if (!isset($config["services"])) {
            return;
        }
        if (!$this->isAssocArray($config["services"])) {
            throw new ConfigException("The 'services' configuration must be an associative array");
        }

        // scan for abstract definitions
        foreach ($config["services"] as $key => $definition) {

            if (!empty($definition["abstract"])) {
                $this->abstractDefinitions[self::SERVICE_CHAR . $this->referenceResolver->aliasThisKey($key, $alias)] = $definition;
                unset ($config["services"][$key]);
            }
        }

        // process services
        foreach ($config["services"] as $key => $definition) {
            // check if this is an alias of another service
            if (!$this->referenceResolver->keyIsAliased($key)) {
                $key = $this->referenceResolver->aliasThisKey($key, $alias);
            }

            if (!empty($definition["stub"])) {
                $container[$key] = function() use ($key, $definition) {
                    return $this->serviceFactory->createStub($key, $definition);
                };
                continue;
            }

            if (!empty($definition["aliasOf"])) {
                // override any existing definitions for this key
                $aliasedService = $definition["aliasOf"];
                $container[$key] = function() use ($container, $aliasedService, $alias) {
                    return $this->serviceFactory->aliasService($aliasedService, $alias);
                };
                $this->serviceAliases[$key] = true;
                continue;
            }


            // check for collisions
            if (isset($container[$key])) {
                if (isset($this->serviceAliases[$key])) {
                    // this service has been aliased by another service. We can ignore the definition.
                    continue;
                }
                throw new ConfigException(sprintf("Tried to define a service named '%s', but that name already exists in the container", $key));
            }

            if (!$this->isAssocArray($definition)) {
                throw new ConfigException("A service definition must be an associative array");
            }
            
            $maxIterations = 20;
            $currentIterations = 0;
            // check if this definition extends an abstract one
            while (!empty($definition["extends"]) && $currentIterations < $maxIterations) {
                $extends = self::SERVICE_CHAR . $this->referenceResolver->aliasThisKey(ltrim($definition["extends"], self::SERVICE_CHAR), $alias);
                if (!isset($this->abstractDefinitions[$extends])) {
                    throw new ConfigException(
                        sprintf(
                            "The service definition for '%s' extends '%s' but there is no abstract definition of that name",
                            $key,
                            $extends
                        )
                    );
                }

                // As calls gets wiped out by the replace_recursive, so we need to store it and merge it separately
                $calls = !empty($definition["calls"]) ? $definition["calls"] : [];
                if (!empty($this->abstractDefinitions[$extends]["calls"])) {
                    $calls = array_merge($calls, $this->abstractDefinitions[$extends]["calls"]);
                }
                unset($definition["extends"]);
                $definition = array_replace_recursive($this->abstractDefinitions[$extends], $definition);
                $definition["calls"] = $calls;
                $currentIterations++;
            }

            // get class
            if (empty($definition["class"])) {
                throw new ConfigException(sprintf("The service definition for %s does not have a class", $key));
            }
            // get class, resolving parameters if necessary
            try {
                $class = $this->referenceResolver->resolveParameter($definition["class"], $container, $alias);
            } catch (ReferenceException $e) {
                throw new ReferenceException("Error resolving class for '$key'. " . $e->getMessage());
            }

            if (!class_exists($class) && !interface_exists($class)) {
                throw new ConfigException(sprintf("The service class '%s' does not exist", $class));
            }

            // factories
            $factory = [];
            if (!empty($definition["factoryMethod"])) {
                $factory["method"] = $definition["factoryMethod"];
            }

            if (!empty($definition["factoryClass"])) {
                // check for malformed definitions ...
                if (empty($factory["method"])) {
                    throw new ConfigException(sprintf("A factory class was specified for '%s', but no method was set", $key));
                }
                //... and non-existent classes
                try {
                    $factoryClass = $this->referenceResolver->resolveParameter($definition["factoryClass"], $container, $alias);
                } catch (ReferenceException $e) {
                    throw new ReferenceException("Error parsing factory class for '$key'. " . $e->getMessage());
                }
                if (!class_exists($factoryClass)) {
                    throw new ConfigException(
                        sprintf("The factory class '%s', for '%s', does not exist", $factoryClass, $key)
                    );
                }
                // make sure the method actually exists on the class
                if (!method_exists($factoryClass, $factory["method"])) {
                    throw new ConfigException(
                        sprintf(
                            "Invalid factory definition. The method '%s' does not exist on the class '%s'",
                            $factory["method"],
                            $factoryClass
                        )
                    );
                }
                $factory["class"] = $factoryClass;
            }

            if (!empty($definition["factoryService"])) {
                // check for malformed definitions
                if (empty($factory["method"])) {
                    throw new ConfigException(sprintf("A factory service was specified for '%s', but no method was set", $key));
                }
                if (!empty($factory["class"])) {
                    throw new ConfigException(sprintf("The definition for '%s' cannot have both a factory class and a factory service", $key));
                }
                // add the service char if it does not exist
                if ($definition["factoryService"][0] != self::SERVICE_CHAR) {
                    $definition["factoryService"] = "@" . $definition["factoryService"];
                }
                // don't alias the service here, we'll do that later when we're about to use it
                $factory["service"] = $definition["factoryService"];
            }
            
            if (!empty($definition["private"])) {
                // if a service is private, create a random key for it and save the reference against the actual service key 
                $hashedName = md5($key . microtime(true));
                
                $this->referenceResolver->registerPrivateService($hashedName, $key);
                $key = $hashedName;
            }
            
            // arguments
            $arguments = !empty($definition["arguments"])? $definition["arguments"]: [];

            // calls / setters
            $calls = !empty($definition["calls"])? $definition["calls"]: [];
            foreach ($calls as $i => $call) {
                $calls[$i] = $this->processCall($call, $i, $key, $class);
            }

            // tags
            if (!empty($definition["tags"])) {
                if (!is_array($definition["tags"])) {
                    throw new ConfigException(sprintf("Error for service '%s': the tags definition was not in the expected array format", $key));
                }
                foreach ($definition["tags"] as $tag => $tagKey) {
                    // tags are either defined as ' - "#tagName" ' or ' "#tagName": "tagKey" ', so
                    // we have to detect the type of $tag and change the variables around if required
                    if (is_numeric($tag)) {
                        $tag = $tagKey;
                        $tagKey = null;
                    }
                    $tag = self::TAG_CHAR . $tag;
                    if (!isset($container[$tag])) {
                        $container[$tag] = function() {
                            return new TagCollection();
                        };
                    }
                    /** @var TagCollection $collection */
                    $collection = $container[$tag];
                    $collection->addService($key, $this->referenceResolver->resolveParameter($tagKey, $container, $alias));
                }
            }

            // add the definition to the container
            $container[$key] = function() use ($class, $factory, $arguments, $calls, $alias) {
                // parse arguments for injected parameters and services
                return $this->serviceFactory->createService($class, $factory, $arguments, $calls, $alias);
            };

        }
    }