src/XML/DOM/ObjectDeserializer.php
protected static function deserializeVarsRec( $children, &$element )
	{
		foreach( $children as $child )
		{
			$name		= $child->getAttribute( 'name' );
			$vartype	= $child->getNodeName();
			if( is_object( $element ) )
			{
				if( !isset( $element->$name ) )
					$element->$name	= NULL;
				$pointer	=& $element->$name;
			}
			else
			{
				if( !isset( $element->$name ) )
					$element[$name]	= NULL;
				$pointer	=& $element[$name];
			}
			
			switch( $vartype )
			{
				case 'boolean':
					$pointer	= (bool) $child->getContent();
					break;
				case 'string':
					$pointer	= utf8_decode( $child->getContent() );
					break;
				case 'integer':
					$pointer	= (int) $child->getContent();
					break;
				case 'double':
					$pointer	= (double) $child->getContent();
					break;
				case 'array':
					$pointer	= array();
					self::deserializeVarsRec( $child->getChildren(), $pointer );
					break;
				case 'object':
					$class		= $child->getAttribute( 'class' );
					$pointer	= new $class();
					self::deserializeVarsRec( $child->getChildren(), $pointer );
					break;
				default:
					$pointer	= NULL;
					break;
			}
		}
	}
protected static function deserializeVarsRec( $children, &$element )
	{
		foreach( $children as $child )
		{
			$name		= $child->getAttribute( 'name' );
			$vartype	= $child->getNodeName();
			if( is_object( $element ) )
			{
				if( !isset( $element->$name ) )
					$element->$name	= NULL;
				$pointer	=& $element->$name;
			}
			else
			{
				if( !isset( $element->$name ) )
					$element[$name]	= NULL;
				$pointer	=& $element[$name];
			}
			
			switch( $vartype )
			{
				case 'boolean':
					$pointer	= (bool) $child->getContent();
					break;
				case 'string':
					$pointer	= utf8_decode( $child->getContent() );
					break;
				case 'integer':
					$pointer	= (int) $child->getContent();
					break;
				case 'double':
					$pointer	= (double) $child->getContent();
					break;
				case 'array':
					$pointer	= array();
					self::deserializeVarsRec( $child->getChildren(), $pointer );
					break;
				case 'object':
					$class		= $child->getAttribute( 'class' );
					$pointer	= new $class();
					self::deserializeVarsRec( $child->getChildren(), $pointer );
					break;
				default:
					$pointer	= NULL;
					break;
			}
		}
	}
protected static function deserializeVarsRec ( $ children , & $ element ) { foreach ( $ children as $ child ) { $ name = $ child -> getAttribute ( 'name' ) ; $ vartype = $ child -> getNodeName ( ) ; if ( is_object ( $ element ) ) { if ( ! isset ( $ element -> $ name ) ) $ element -> $ name = NULL ; $ pointer = & $ element -> $ name ; } else { if ( ! isset ( $ element -> $ name ) ) $ element [ $ name ] = NULL ; $ pointer = & $ element [ $ name ] ; } switch ( $ vartype ) { case 'boolean' : $ pointer = ( bool ) $ child -> getContent ( ) ; break ; case 'string' : $ pointer = utf8_decode ( $ child -> getContent ( ) ) ; break ; case 'integer' : $ pointer = ( int ) $ child -> getContent ( ) ; break ; case 'double' : $ pointer = ( double ) $ child -> getContent ( ) ; break ; case 'array' : $ pointer = array ( ) ; self :: deserializeVarsRec ( $ child -> getChildren ( ) , $ pointer ) ; break ; case 'object' : $ class = $ child -> getAttribute ( 'class' ) ; $ pointer = new $ class ( ) ; self :: deserializeVarsRec ( $ child -> getChildren ( ) , $ pointer ) ; break ; default : $ pointer = NULL ; break ; } } }
Adds nested Vars to an Element by their Type while supporting nested Arrays.
@access		protected
@param		array		$children		Array of Vars to add
@param		mixed		$element		current Position in Object
@return		string
Adds nested Vars to an Element by their Type while supporting nested Arrays .