public function getColumns()
{
if (AbstractStorage::MANY_TO_ONE == $this->getFieldDefinition()->getObjectRelation() || AbstractStorage::ONE_TO_ONE == $this->getFieldDefinition()->getObjectRelation()) {
$foreignObjectDefinition = $this->objects->getDefinition($this->getFieldDefinition()->getObject());
if (!$foreignObjectDefinition) {
throw new ObjectNotFoundException(sprintf('ObjectKey `%s` not found in field `%s` of object `%s`', $this->getFieldDefinition()->getObject(), $this->getFieldDefinition()->getId(), $this->getFieldDefinition()->getObjectDefinition()->getId()));
}
/** @var $columns ColumnDefinition[] */
$columns = [];
foreach ($foreignObjectDefinition->getPrimaryKeys() as $pk) {
$fieldColumns = $pk->getFieldType()->getColumns();
$columns = array_merge($columns, $fieldColumns);
}
//rename columns to fieldId+column.id
foreach ($columns as &$column) {
$column = clone $column;
$column->setName($this->getFieldDefinition()->getId() . ucfirst($column->getName()));
}
return $columns;
}
return [];
}