Beispiel #1
0
 public static function populateInstance(Mapper $instance, $mappedEntity)
 {
     $class = $mappedEntity->attributes()->class;
     $instance->setTable($mappedEntity->attributes()->table->__toString());
     $instance->setClass($class->__toString());
     // propertys
     $props = $mappedEntity->property;
     $propertys = array();
     foreach ($props as $property) {
         $name = $property->attributes()->name->__toString();
         $column = $property->attributes()->column ? $property->attributes()->column->__toString() : null;
         $type = $property->attributes()->type ? $property->attributes()->type->__toString() : null;
         $propertys[$name] = new Property($name, $column, $type);
     }
     $instance->setPropertys($propertys);
     // relations
     $rels = $mappedEntity->relation;
     $relations = array();
     foreach ($rels as $relation) {
         $relInstance = new Relation();
         $relInstance->setCardinality($relation->attributes()->cardinality->__toString());
         $relInstance->setEntity($relation->attributes()->entity->__toString());
         $relInstance->setName($relation->attributes()->name->__toString());
         $relInstance->setTable($relation->attributes()->table->__toString());
         if (is_object($relation->attributes()->lazy)) {
             $relInstance->setLazy($relation->attributes()->lazy->__toString());
         }
         $relInstance->setLocalColumn($relation->attributes()->localColumn->__toString());
         $relInstance->setForeignColumn($relation->attributes()->foreignColumn->__toString());
         $relations[$relInstance->getName()] = $relInstance;
     }
     $instance->setRelations($relations);
     // filters
     $fils = $mappedEntity->filter;
     $filters = array();
     foreach ($fils as $filter) {
         $filInstance = new Filter();
         $filInstance->setName($filter->attributes()->name->__toString());
         $filInstance->setItemsPerPage($filter->attributes()->perPage->__toString());
         $filteredColumns = $filter->attributes()->columns->__toString();
         $columList = explode(",", $filteredColumns);
         foreach ($columList as $columnName) {
             $filInstance->addFilteredColumn($columnName);
         }
         $filters[$filInstance->getName()] = $filInstance;
     }
     $instance->setFilters($filters);
 }