Register given services under given service group

@param string       $serviceGroup
@param ConfigObject $config
@param bool         $overwrite Overwrite service if it has been registered before (Default: false)
163665
public function registerServices($serviceGroup, ConfigObject $config, $overwrite = false)
    {
        foreach ($config as $serviceKey => $serviceConfig) {
            $this->registerService($serviceGroup . '.' . $serviceKey, $serviceConfig, $overwrite);
        }
    }
433060
private function initializeService($serviceId, array $constructorArguments) {
		
		if(!isset($this->config->services[$serviceId])) {
			throw new ApplicationException(sprintf("Service '%s' not configured.", $serviceId));
		}

		$configData = $this->config->services[$serviceId];

		// get class name

		$class	= $configData['class'];

		// create instance and pass additional parameters to constructor

		try {
			$service = new $class(...$constructorArguments);
		}
		catch(\Exception $e) {
			throw new ApplicationException(sprintf("Instancing of service '%s' failed. Error: %s", $serviceId, $e->getMessage()));
		}

		// check whether instance implements ServiceInterface  

		if(!$service instanceof ServiceInterface) {
			throw new ApplicationException(sprintf("Service '%s' (class %s) does not implement the ServiceInterface.", $serviceId, $class));
		}

		// set parameters
		
		$service->setParameters($configData['parameters']);
		
		return $service;

	}
1199200
private function registerService($dir, $namespace, $server, $moduleSuffix = '') {
        $files = [];
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    $filetype = filetype($dir . $file);
                    $ext = pathinfo($file, PATHINFO_EXTENSION);
                    if ($filetype == 'file' && $ext == 'php') {
                        $files [] = substr($file, 0, -4);
                    }
                }
                closedir($dh);
            }
        }
        if (count($files) > 0) {
            foreach ($files as $filename) {
                $module = strtolower(str_replace('Service', '', $filename)) . $moduleSuffix;
                $className = $namespace . $filename;
                $class = new $className($this->yiiConfig, $server);
                $this->add($class, $className, $module);
            }
            unset($filename);
        }
        unset($files);
    }
351330
public function load(Config $config)
    {
        $sys = new Service\SystemService();

        $config->set('CWD', $sys->getCurrentWorkingDirectory());
    }
1026707
public function registerService($serviceKey, ConfigurableService $service, $allowOverride = true)
    {
        if ($allowOverride || ! $this->getServiceLocator()->has($serviceKey)) {
            $this->getServiceManager()->register($serviceKey, $service);
        }
    }
1292585
public function setConfig(array $config, $overwrite = false) 
    {
        if ($overwrite) {
            $this->config = $this->_mergeConfig($this->config, $config);
        } else {
            $this->config = $this->_mergeConfig($config, $this->config);
        }
    }
996317
protected function registerServiceProviders(Repository $config)
    {
        foreach ($this->getComponentsFromConfig($config, 'register', getenv('APP_ENV')) as $provider) {
            $this->app->register($provider);

            $config->push('app.providers', $provider);
        }
    }
400240
protected function registerServices()
    {
        foreach (self::$diMap as $serviceKey => $serviceClass) {
            if (\is_int($serviceKey)) {
                $this->register(new $serviceClass);
            } else {
                $this[$serviceKey] = function ($c) use ($serviceClass) {
                    return new $serviceClass($c);
                };
            }
        }
    }
296752
public function load(string $configPath, $overwrite = false): void
    {
        if (!file_exists($configPath)) {
            return;
        }
        $config = include $configPath;
        if (!is_array($config) && !is_object($config)) {
            return;
        }
        if (is_object($config)) {
            $config = get_object_vars($config);
        }
        $this->loadArray($config, $overwrite);
    }
21746
public function registerConfiguredHooks(string $config = '')
    {
        if (empty($config)) {
            $config = 'app.hooks';
        }

        $hooks = Collection::make($this->config[$config]);

        (new HooksRepository($this))->load($hooks->all());
    }
1038679
private function registerPlugins(ConfigObject $config)
    {
        // antiflood
        if ($config->get('AntiFlood', false)) {
            $antiflood = new \Swift_Plugins_AntiFloodPlugin($config->get('AntiFlood.Threshold', 99),
                $config->get('AntiFlood.Sleep', 1));
            $this->mailer->registerPlugin($antiflood);
        }

        // array logger
        if ($config->get('Debug', false)) {
            $this->logger = new \Swift_Plugins_Loggers_ArrayLogger();
            $this->mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($this->logger));
        }
    }
259356
public function overrideAppConfig(array $newConfig = [])
    {
        $applicationConfig = $this->getApplicationConfig();

        if (is_array($applicationConfig) && !isset($applicationConfig['service_manager']['factories']['ServiceListenerInterface'])) {
            $appConfig = ArrayUtils::merge($applicationConfig, [
                'service_manager' => [
                    'factories' => [
                        'ServiceListenerInterface' => [$this, 'serviceListenerInterfaceFactory'],
                    ]
                ]
            ]);

            $this->setApplicationConfig($appConfig);
        }

        $this->addOverrideConfig($newConfig);
    }
515124
private function setupStateHandlerRegistration(SubscriptionGroup $subscriptionGroup)
    {
        /** @var StateHandlerRegistration $stateHandlerRegistration */
        foreach ($this->stateHandlerRegistrations as $stateHandlerRegistration) {
            if ($stateHandlerRegistration->handlesStateFor($subscriptionGroup)) {
                $this->stateHandlerMap->attach($subscriptionGroup, $stateHandlerRegistration);
                return;
            }
        }
        $this->stateHandlerMap->attach($subscriptionGroup, null);
    }
1045269
@Override
	public IServiceRegistration registerService(String clazz, Object service,
			Dictionary<String, String> properties) {
		final String sourceMethod = "registerService"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(PlatformServicesImpl.class.getName(), sourceMethod, new Object[]{clazz, service, properties});
		}
		ServiceRegistrationOSGi serviceRegistrationOSGi = null;
		ServiceRegistration<?> serviceRegistration = null;
		BundleContext bundleContext = Activator.getBundleContext();
		if (bundleContext != null) {
			serviceRegistration = bundleContext.registerService(clazz, service,
					properties);
			serviceRegistrationOSGi = new ServiceRegistrationOSGi(serviceRegistration);
		}
		if (isTraceLogging) {
			log.exiting(PlatformServicesImpl.class.getName(), sourceMethod, serviceRegistrationOSGi);
		}
		return serviceRegistrationOSGi;
	}
500254
public synchronized MessageRouterConfigListenerImpl register(BundleContext bundleContext) {
        if (serviceRegistration != null) {
            return this; // Already registered.
        }

        Dictionary<String, Object> props = new Hashtable<String, Object>(1);
        props.put(Constants.SERVICE_VENDOR, "IBM");

        // register the ManagedService that will handle the config
        serviceRegistration = bundleContext.registerService(MessageRouterConfigListener.class, this, props);
        return this;
    }
253731
protected function registerBindings(Container $container, ConfigRepository $config)
    {
        $container->bind(OAuth2Service::class, function ($container) use ($config) {
            return $this->createService($container, $config[self::CONFIG_KEY]);
        });

        $container->alias(OAuth2Service::class, OAuth2ServiceContract::class);
    }
1294165
protected function activate($serviceName, $serviceConfig)
    {
        $activator = $this->activatorFactory->getActivator($serviceName, $serviceConfig);

        return $activator->createInstance($this, $serviceName, $serviceConfig);
    }