public function toArrayRawI18N(Entity $entity, array $locales=[], $depth=0) {
		if(!$locales)
			$locales = $entity->getLocales();
		$res = [];

		foreach($entity->getDefinition()->properties() as $name=>$property) {
			if($property->get('i18n')) {
				foreach($locales as $locale) {
					if($entity->getDefinition()->property($name)->get('many'))
						$res[$name][$locale] = $entity->get($name, $locale)->all();
					else
						$res[$name][$locale] = $entity->get($name, $locale);
				}
			}
			elseif($entity->getDefinition()->property($name)->get('type') == 'entity') {
				if($depth < 1)
					continue;
				if($entity->getDefinition()->property($name)->get('many')) {
					foreach($entity->get($name) as $entity)
						$res[$name][] = $entity->toArrayRawI18N($locales, $depth-1);
				}
				else
					$res[$name] = $entity->toArrayRawI18N($locales, $depth-1);
			}
			elseif($entity->getDefinition()->property($name)->get('many'))
				$res[$name] = $entity->get($name)->all();
			else
				$res[$name] = $entity->get($name);
		}

		return $res;
	}
public function toArrayRawI18N(Entity $entity, array $locales=[], $depth=0) {
		if(!$locales)
			$locales = $entity->getLocales();
		$res = [];

		foreach($entity->getDefinition()->properties() as $name=>$property) {
			if($property->get('i18n')) {
				foreach($locales as $locale) {
					if($entity->getDefinition()->property($name)->get('many'))
						$res[$name][$locale] = $entity->get($name, $locale)->all();
					else
						$res[$name][$locale] = $entity->get($name, $locale);
				}
			}
			elseif($entity->getDefinition()->property($name)->get('type') == 'entity') {
				if($depth < 1)
					continue;
				if($entity->getDefinition()->property($name)->get('many')) {
					foreach($entity->get($name) as $entity)
						$res[$name][] = $entity->toArrayRawI18N($locales, $depth-1);
				}
				else
					$res[$name] = $entity->toArrayRawI18N($locales, $depth-1);
			}
			elseif($entity->getDefinition()->property($name)->get('many'))
				$res[$name] = $entity->get($name)->all();
			else
				$res[$name] = $entity->get($name);
		}

		return $res;
	}
public function toArrayRawI18N ( Entity $ entity , array $ locales = [ ] , $ depth = 0 ) { if ( ! $ locales ) $ locales = $ entity -> getLocales ( ) ; $ res = [ ] ; foreach ( $ entity -> getDefinition ( ) -> properties ( ) as $ name => $ property ) { if ( $ property -> get ( 'i18n' ) ) { foreach ( $ locales as $ locale ) { if ( $ entity -> getDefinition ( ) -> property ( $ name ) -> get ( 'many' ) ) $ res [ $ name ] [ $ locale ] = $ entity -> get ( $ name , $ locale ) -> all ( ) ; else $ res [ $ name ] [ $ locale ] = $ entity -> get ( $ name , $ locale ) ; } } elseif ( $ entity -> getDefinition ( ) -> property ( $ name ) -> get ( 'type' ) == 'entity' ) { if ( $ depth < 1 ) continue ; if ( $ entity -> getDefinition ( ) -> property ( $ name ) -> get ( 'many' ) ) { foreach ( $ entity -> get ( $ name ) as $ entity ) $ res [ $ name ] [ ] = $ entity -> toArrayRawI18N ( $ locales , $ depth - 1 ) ; } else $ res [ $ name ] = $ entity -> toArrayRawI18N ( $ locales , $ depth - 1 ) ; } 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 with translations.
@param  Entity  $entity
@param  array $locales
@param  integer $depth
@return array
Convert entity to a raw array with translations .