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;

	}
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;

	}
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 ; }
create and initialize a service instance

@param string $serviceId
@param array $constructorArguments
@throws ApplicationException
@return ServiceInterface
create and initialize a service instance