src/EntityDescriptor/EntityDescriptor.php
public static function load($name, $class=null) {
		$descriptorPath = ENTITY_DESCRIPTOR_CONFIG_PATH.$name;
		$cache = new FSCache(self::DESCRIPTORCLASS, $name, filemtime(YAML::getFilePath($descriptorPath)));
		
		// Comment when editing class and entity field types
		$descriptor	= null;
		try {
			if( !defined('ENTITY_ALWAYS_RELOAD')
					&& $cache->get($descriptor)
					&& isset($descriptor->version)
					&& $descriptor->version==self::VERSION ) {
				return $descriptor;
			}
		} catch( Exception $e ) {
			// If file is corrupted (version mismatch ?)
			$cache->reset();
		}
		// Unable to get from cache, building new one
		
		$conf = YAML::build($descriptorPath, true);
		if( empty($conf->fields) ) {
			throw new \Exception('Descriptor file for "'.$name.'" is corrupted, empty or not found, there is no field.');
		}
		// Build descriptor
		//    Parse Config file
		//      Fields
		$fields	= array();
		if( !empty($conf->parent) ) {
			if( !is_array($conf->parent) ) {
				$conf->parent = array($conf->parent);
			}
			foreach( $conf->parent as $p ) {
				$p	= static::load($p);
				if( !empty($p) ) {
					$fields	= array_merge($fields, $p->getFields());
				}
			}
		}
		$IDField = $class ? $class::getIDField() : self::IDFIELD;
		$fields[$IDField] = FieldDescriptor::buildIDField($IDField);
		foreach( $conf->fields as $fieldName => $fieldInfos ) {
			$fields[$fieldName]	= FieldDescriptor::parseType($fieldName, $fieldInfos);
		}

		//      Indexes
		$indexes = array();
		if( !empty($conf->indexes) ) {
			foreach( $conf->indexes as $index ) {
				$iType		= static::parseType(null, $index);
				$indexes[]	= (object) array('name'=>$iType->default, 'type'=>strtoupper($iType->type), 'fields'=>$iType->args);
			}
		}
		//    Save cache output
		$descriptor	= new EntityDescriptor($name, $fields, $indexes, $class);
		if( !empty($conf->flags) ) {
			if( in_array(self::FLAG_ABSTRACT, $conf->flags) ) {
				$descriptor->setAbstract(true);
			}
		}
// 		debug('Entity load('.$name.')', $fields);
		$cache->set($descriptor);
		return $descriptor;
	}
public static function load($name, $class=null) {
		$descriptorPath = ENTITY_DESCRIPTOR_CONFIG_PATH.$name;
		$cache = new FSCache(self::DESCRIPTORCLASS, $name, filemtime(YAML::getFilePath($descriptorPath)));
		
		// Comment when editing class and entity field types
		$descriptor	= null;
		try {
			if( !defined('ENTITY_ALWAYS_RELOAD')
					&& $cache->get($descriptor)
					&& isset($descriptor->version)
					&& $descriptor->version==self::VERSION ) {
				return $descriptor;
			}
		} catch( Exception $e ) {
			// If file is corrupted (version mismatch ?)
			$cache->reset();
		}
		// Unable to get from cache, building new one
		
		$conf = YAML::build($descriptorPath, true);
		if( empty($conf->fields) ) {
			throw new \Exception('Descriptor file for "'.$name.'" is corrupted, empty or not found, there is no field.');
		}
		// Build descriptor
		//    Parse Config file
		//      Fields
		$fields	= array();
		if( !empty($conf->parent) ) {
			if( !is_array($conf->parent) ) {
				$conf->parent = array($conf->parent);
			}
			foreach( $conf->parent as $p ) {
				$p	= static::load($p);
				if( !empty($p) ) {
					$fields	= array_merge($fields, $p->getFields());
				}
			}
		}
		$IDField = $class ? $class::getIDField() : self::IDFIELD;
		$fields[$IDField] = FieldDescriptor::buildIDField($IDField);
		foreach( $conf->fields as $fieldName => $fieldInfos ) {
			$fields[$fieldName]	= FieldDescriptor::parseType($fieldName, $fieldInfos);
		}

		//      Indexes
		$indexes = array();
		if( !empty($conf->indexes) ) {
			foreach( $conf->indexes as $index ) {
				$iType		= static::parseType(null, $index);
				$indexes[]	= (object) array('name'=>$iType->default, 'type'=>strtoupper($iType->type), 'fields'=>$iType->args);
			}
		}
		//    Save cache output
		$descriptor	= new EntityDescriptor($name, $fields, $indexes, $class);
		if( !empty($conf->flags) ) {
			if( in_array(self::FLAG_ABSTRACT, $conf->flags) ) {
				$descriptor->setAbstract(true);
			}
		}
// 		debug('Entity load('.$name.')', $fields);
		$cache->set($descriptor);
		return $descriptor;
	}
public static function load ( $ name , $ class = null ) { $ descriptorPath = ENTITY_DESCRIPTOR_CONFIG_PATH . $ name ; $ cache = new FSCache ( self :: DESCRIPTORCLASS , $ name , filemtime ( YAML :: getFilePath ( $ descriptorPath ) ) ) ; // Comment when editing class and entity field types $ descriptor = null ; try { if ( ! defined ( 'ENTITY_ALWAYS_RELOAD' ) && $ cache -> get ( $ descriptor ) && isset ( $ descriptor -> version ) && $ descriptor -> version == self :: VERSION ) { return $ descriptor ; } } catch ( Exception $ e ) { // If file is corrupted (version mismatch ?) $ cache -> reset ( ) ; } // Unable to get from cache, building new one $ conf = YAML :: build ( $ descriptorPath , true ) ; if ( empty ( $ conf -> fields ) ) { throw new \ Exception ( 'Descriptor file for "' . $ name . '" is corrupted, empty or not found, there is no field.' ) ; } // Build descriptor //    Parse Config file //      Fields $ fields = array ( ) ; if ( ! empty ( $ conf -> parent ) ) { if ( ! is_array ( $ conf -> parent ) ) { $ conf -> parent = array ( $ conf -> parent ) ; } foreach ( $ conf -> parent as $ p ) { $ p = static :: load ( $ p ) ; if ( ! empty ( $ p ) ) { $ fields = array_merge ( $ fields , $ p -> getFields ( ) ) ; } } } $ IDField = $ class ? $ class :: getIDField ( ) : self :: IDFIELD ; $ fields [ $ IDField ] = FieldDescriptor :: buildIDField ( $ IDField ) ; foreach ( $ conf -> fields as $ fieldName => $ fieldInfos ) { $ fields [ $ fieldName ] = FieldDescriptor :: parseType ( $ fieldName , $ fieldInfos ) ; } //      Indexes $ indexes = array ( ) ; if ( ! empty ( $ conf -> indexes ) ) { foreach ( $ conf -> indexes as $ index ) { $ iType = static :: parseType ( null , $ index ) ; $ indexes [ ] = ( object ) array ( 'name' => $ iType -> default , 'type' => strtoupper ( $ iType -> type ) , 'fields' => $ iType -> args ) ; } } //    Save cache output $ descriptor = new EntityDescriptor ( $ name , $ fields , $ indexes , $ class ) ; if ( ! empty ( $ conf -> flags ) ) { if ( in_array ( self :: FLAG_ABSTRACT , $ conf -> flags ) ) { $ descriptor -> setAbstract ( true ) ; } } // 		debug('Entity load('.$name.')', $fields); $ cache -> set ( $ descriptor ) ; return $ descriptor ; }
Load an entity descriptor from configuraiton file

@param string $name
@param string $class
@throws Exception
@return EntityDescriptor
Load an entity descriptor from configuraiton file