protected function loadMetadataForTable(Table $table)
{
$tblName = $table->getName();
if (isset($this->defaultAliases[$tblName])) {
$className = $this->defaultAliases[$tblName];
} else {
$className = $tblName;
$this->unmapped[] = $tblName;
}
$contentKey = $this->getContenttypeFromAlias($table->getOption('alias'));
$this->metadata[$className] = [];
$this->metadata[$className]['identifier'] = $table->getPrimaryKey();
$this->metadata[$className]['table'] = $table->getName();
$this->metadata[$className]['boltname'] = $contentKey;
foreach ($table->getColumns() as $colName => $column) {
$mapping = ['fieldname' => $column->getName(), 'attribute' => $this->camelize($column->getName()), 'type' => $column->getType()->getName(), 'fieldtype' => $this->getFieldTypeFor($contentKey, $column), 'length' => $column->getLength(), 'nullable' => $column->getNotnull(), 'platformOptions' => $column->getPlatformOptions(), 'precision' => $column->getPrecision(), 'scale' => $column->getScale(), 'default' => $column->getDefault(), 'columnDefinition' => $column->getColumnDefinition(), 'autoincrement' => $column->getAutoincrement()];
$this->metadata[$className]['fields'][$colName] = $mapping;
if (isset($this->contenttypes[$contentKey]) && isset($this->contenttypes[$contentKey]['fields'][$colName])) {
$this->metadata[$className]['fields'][$colName]['data'] = $this->contenttypes[$contentKey]['fields'][$colName];
}
}
// This loop checks the contenttypes definition for any non-db fields and adds them.
if ($contentKey && isset($this->contenttypes[$contentKey])) {
$this->setRelations($contentKey, $className, $table);
$this->setIncomingRelations($contentKey, $className);
$this->setTaxonomies($contentKey, $className, $table);
$this->setTemplatefields($contentKey, $className, $table);
$this->setRepeaters($contentKey, $className);
}
foreach ($this->getAliases() as $alias => $table) {
if (array_key_exists($table, $this->metadata)) {
$this->metadata[$alias] = $this->metadata[$table];
} elseif (array_key_exists($table, $this->defaultAliases) && array_key_exists($this->defaultAliases[$table], $this->metadata)) {
$this->metadata[$alias] = $this->metadata[$this->defaultAliases[$table]];
}
}
}