public function toArrayRaw(Entity $entity, $depth=0) {
		$res = [];

		foreach($entity->getDefinition()->properties() as $name=>$property) {
			if($entity->getDefinition()->property($name) instanceof Property\EntityProperty) {
				if($depth < 1)
					$res[$name] = $entity->get($name, null, false);
				else {
					if($entity->getDefinition()->property($name)->get('many')) {
						foreach($entity->get($name, null, false) as $subentity)
							$res[$name][] = $subentity->toArrayRaw($depth-1);
					}
					else {
						if($subentity = $entity->get($name, null, false))
							$res[$name] = $subentity->toArrayRaw($depth-1);
						else
							$res[$name] = null;
					}
				}
			}
			elseif($entity->getDefinition()->property($name)->get('many'))
				$res[$name] = $entity->get($name)->all();
			else
				$res[$name] = $entity->get($name);
		}

		return $res;
	}
public function toArrayRaw(Entity $entity, $depth=0) {
		$res = [];

		foreach($entity->getDefinition()->properties() as $name=>$property) {
			if($entity->getDefinition()->property($name) instanceof Property\EntityProperty) {
				if($depth < 1)
					$res[$name] = $entity->get($name, null, false);
				else {
					if($entity->getDefinition()->property($name)->get('many')) {
						foreach($entity->get($name, null, false) as $subentity)
							$res[$name][] = $subentity->toArrayRaw($depth-1);
					}
					else {
						if($subentity = $entity->get($name, null, false))
							$res[$name] = $subentity->toArrayRaw($depth-1);
						else
							$res[$name] = null;
					}
				}
			}
			elseif($entity->getDefinition()->property($name)->get('many'))
				$res[$name] = $entity->get($name)->all();
			else
				$res[$name] = $entity->get($name);
		}

		return $res;
	}
public function toArrayRaw ( Entity $ entity , $ depth = 0 ) { $ res = [ ] ; foreach ( $ entity -> getDefinition ( ) -> properties ( ) as $ name => $ property ) { if ( $ entity -> getDefinition ( ) -> property ( $ name ) instanceof Property \ EntityProperty ) { if ( $ depth < 1 ) $ res [ $ name ] = $ entity -> get ( $ name , null , false ) ; else { if ( $ entity -> getDefinition ( ) -> property ( $ name ) -> get ( 'many' ) ) { foreach ( $ entity -> get ( $ name , null , false ) as $ subentity ) $ res [ $ name ] [ ] = $ subentity -> toArrayRaw ( $ depth - 1 ) ; } else { if ( $ subentity = $ entity -> get ( $ name , null , false ) ) $ res [ $ name ] = $ subentity -> toArrayRaw ( $ depth - 1 ) ; else $ res [ $ name ] = null ; } } } elseif ( $ entity -> getDefinition ( ) -> property ( $ name ) -> get ( 'many' ) ) $ res [ $ name ] = $ entity -> get ( $ name ) -> all ( ) ; else $ res [ $ name ] = $ entity -> get ( $ name ) ; } return $ res ; }
Convert entity to a raw array.
@param  Entity  $entity
@param  integer $depth
@return array
Convert entity to a raw array .