Ejemplo n.º 1
0
 /**
  * Create Table instance
  *
  * @param string                  $tableName Table name
  * @param NenoContentElementGroup $group     Group
  *
  * @return NenoContentElementTable
  */
 public static function createTableInstance($tableName, NenoContentElementGroup $group)
 {
     /* @var $db NenoDatabaseDriverMysqlx */
     $db = JFactory::getDbo();
     // Create an array with the table information
     $tableData = array('tableName' => $tableName, 'primaryKey' => $db->getPrimaryKey($tableName), 'translate' => !$group->isOtherGroup(), 'group' => $group);
     // Create ContentElement object
     $table = new NenoContentElementTable($tableData);
     // Get all the columns a table contains
     $fields = $db->getTableColumns($table->getTableName());
     foreach ($fields as $fieldName => $fieldType) {
         $fieldData = array('fieldName' => $fieldName, 'fieldType' => $fieldType, 'translate' => NenoContentElementField::isTranslatableType($fieldType), 'table' => $table);
         $field = new NenoContentElementField($fieldData);
         $table->addField($field);
     }
     return $table;
 }