src/Application/Config.php
private function parseServicesSettings(\DOMNode $services) {

		if(is_null($this->services)) {
			$this->services = [];
		}

		foreach($services->getElementsByTagName('service') as $service) {

			if(!($id = $service->getAttribute('id'))) {
				throw new ConfigException('Service without id found.');
			}

			if(isset($this->services[$id])) {
				throw new ConfigException(sprintf("Service '%s' has already been defined.", $id));
			}

			if(!($class = $service->getAttribute('class'))) {
				throw new ConfigException(sprintf("No class for service '%s' configured.", $id));
			}

			// clean path delimiters, prepend leading backslash, and replace slashes with backslashes

			$class = '\\' . ltrim(str_replace('/', '\\', $class), '/\\');

			// store parsed information

			$this->services[$id] = [
				'class'			=> $class,
				'parameters'	=> []
			];

			foreach($service->getElementsByTagName('parameter') as $parameter) {

				$name = $parameter->getAttribute('name');
				$value = $parameter->getAttribute('value');

				if(!$name) {
					throw new ConfigException(sprintf("A parameter for service '%s' has no name.", $id));
				}

				$this->services[$id]['parameters'][$name] = $value;

			}

		}

	}
private function parseServicesSettings(\DOMNode $services) {

		if(is_null($this->services)) {
			$this->services = [];
		}

		foreach($services->getElementsByTagName('service') as $service) {

			if(!($id = $service->getAttribute('id'))) {
				throw new ConfigException('Service without id found.');
			}

			if(isset($this->services[$id])) {
				throw new ConfigException(sprintf("Service '%s' has already been defined.", $id));
			}

			if(!($class = $service->getAttribute('class'))) {
				throw new ConfigException(sprintf("No class for service '%s' configured.", $id));
			}

			// clean path delimiters, prepend leading backslash, and replace slashes with backslashes

			$class = '\\' . ltrim(str_replace('/', '\\', $class), '/\\');

			// store parsed information

			$this->services[$id] = [
				'class'			=> $class,
				'parameters'	=> []
			];

			foreach($service->getElementsByTagName('parameter') as $parameter) {

				$name = $parameter->getAttribute('name');
				$value = $parameter->getAttribute('value');

				if(!$name) {
					throw new ConfigException(sprintf("A parameter for service '%s' has no name.", $id));
				}

				$this->services[$id]['parameters'][$name] = $value;

			}

		}

	}
private function parseServicesSettings ( \ DOMNode $ services ) { if ( is_null ( $ this -> services ) ) { $ this -> services = [ ] ; } foreach ( $ services -> getElementsByTagName ( 'service' ) as $ service ) { if ( ! ( $ id = $ service -> getAttribute ( 'id' ) ) ) { throw new ConfigException ( 'Service without id found.' ) ; } if ( isset ( $ this -> services [ $ id ] ) ) { throw new ConfigException ( sprintf ( "Service '%s' has already been defined." , $ id ) ) ; } if ( ! ( $ class = $ service -> getAttribute ( 'class' ) ) ) { throw new ConfigException ( sprintf ( "No class for service '%s' configured." , $ id ) ) ; } // clean path delimiters, prepend leading backslash, and replace slashes with backslashes $ class = '\\' . ltrim ( str_replace ( '/' , '\\' , $ class ) , '/\\' ) ; // store parsed information $ this -> services [ $ id ] = [ 'class' => $ class , 'parameters' => [ ] ] ; foreach ( $ service -> getElementsByTagName ( 'parameter' ) as $ parameter ) { $ name = $ parameter -> getAttribute ( 'name' ) ; $ value = $ parameter -> getAttribute ( 'value' ) ; if ( ! $ name ) { throw new ConfigException ( sprintf ( "A parameter for service '%s' has no name." , $ id ) ) ; } $ this -> services [ $ id ] [ 'parameters' ] [ $ name ] = $ value ; } } }
parse settings for services
only service id, class and parameters are parsed
lazy initialization is handled by Application instance

@param \DOMNode $services
@throws ConfigException
parse settings for services only service id class and parameters are parsed lazy initialization is handled by Application instance