Example #1
0
 /**
  * Builds a Table object using a Php class definition
  *
  * This takes care of excluded properties, so buildLinkTable() should be called
  * before buildClassTable().
  *
  * @param $class      Reflection_Class
  * @param $more_field Column
  * @return Table
  */
 private function buildClassTable(Reflection_Class $class, $more_field)
 {
     $table_name = Dao::current()->storeNameOf($class->name);
     $table = new Table($table_name);
     if (!in_array('id', $this->excluded_properties)) {
         $table->addColumn(Column::buildId());
     }
     if ($more_field) {
         $table->addColumn($more_field);
     }
     if ($class->isAbstract()) {
         $table->addColumn(new Column('class', 'varchar(255)'));
     } else {
         foreach ($class->accessProperties() as $property) {
             if (!in_array($property->name, $this->excluded_properties)) {
                 $type = $property->getType();
                 if (($type->isMultipleString() || !$type->isMultiple()) && !$property->isStatic()) {
                     $table->addColumn(Column::buildProperty($property));
                     if ($property->getAnnotation('link')->value == Link_Annotation::OBJECT && $property->getAnnotation('store')->value != 'string') {
                         $class_name = $property->getType()->asString();
                         $this->dependencies_context[$class_name] = $class_name;
                         $table->addForeignKey(Foreign_Key::buildProperty($table_name, $property));
                         $table->addIndex(Index::buildLink($property->getAnnotation('storage')->value));
                     }
                 }
             }
         }
     }
     return $table;
 }