Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/Attribute/AttributeOrderTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*
* @package MetaModels/attribute_file
* @author Sven Baumann <[email protected]>
* @author Benedict Zinke <[email protected]>
* @copyright 2012-2019 The MetaModels team.
* @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
Expand Down Expand Up @@ -42,6 +43,13 @@ class AttributeOrderTypeFactory implements IAttributeTypeFactory
*/
protected $tableManipulator;

/**
* Cache table columns.
*
* @var array
*/
private $tableColumns = [];

/**
* {@inheritDoc}
*
Expand Down Expand Up @@ -78,9 +86,14 @@ public function getTypeIcon()
*/
public function createInstance($information, $metaModel)
{
$columnName = ($information['colname'] ?? null);
$tableColumns = $this->connection->getSchemaManager()->listTableColumns($metaModel->getTableName());
if (!$columnName || !\array_key_exists($columnName, $tableColumns)) {
$columnName = ($information['colname'] ?? null);
$tableName = $metaModel->getTableName();

if (!isset($this->tableColumns[$tableName])) {
$this->tableColumns[$tableName] = $this->connection->getSchemaManager()->listTableColumns($tableName);
}

if (!$columnName || !\array_key_exists($columnName, $this->tableColumns[$tableName])) {
return null;
}

Expand Down