/** * Set the array of record objects * * @return string $error */ public function setRecords() { $recordsData = $this->recordManagementRepository->getRecordsFromTables($this->table->getColumns(), $this->table->getTableNames(), $this->conditions); $primaryKeyColumns = $this->recordManagementRepository->getPrimaryKeyColumns($this->table->getTableNames()); if (!isset($recordsData['error'])) { foreach ($recordsData as $data) { $primaryKeys = array(); foreach ($primaryKeyColumns as $primaryKeyColumn) { $primaryKeys[$primaryKeyColumn['name']] = $data[$primaryKeyColumn['name']]; } $this->records[] = new \Frohland\Ezqueries\Domain\Model\Record($data, $primaryKeys); } } // Change column labels with the value of the labelFrom column (for detail and edit view) if ($this->table->getTableType() == 'detail' || $this->table->getTableType() == 'edit') { $columnTypes = $this->table->getColumnTypes(); $columns = $this->table->getSelectedColumns(); foreach ($columns as &$column) { if (isset($columnTypes[$column['name']]['labelFrom'])) { $data = $this->records[0]->getData(); $columnName = $data[$columnTypes[$column['name']]['labelFrom']]; if ($columnName !== NULL && $columnName !== '') { $column['columnName'] = $data[$columnTypes[$column['name']]['labelFrom']]; } else { unset($columns[$column['name']]); } } } unset($column); $this->table->setSelectedColumns($columns); } if (isset($recordsData['error'])) { return $recordsData['error']; } else { return 'noError'; } }