/** * * @return array * @param Column $resultColumn */ public function resolveResultColumn(Column $resultColumn, array &$resultRow, ExecutionContext $context) { $schemaSource = $resultColumn->getSchemaSource(); switch (true) { case $schemaSource instanceof ValuePart: $columnIdentifier = $schemaSource->generateAlias(); $columnData = $this->resolveValue($schemaSource, $context); $resultRow[$columnIdentifier] = $columnData; break; case $schemaSource instanceof Column: $columnIdentifier = (string) $schemaSource; $columnData = $context->getCurrentSourceRow()[$columnIdentifier]; $resultRow[$columnIdentifier] = $columnData; break; case $resultColumn->getIsAllColumnsFromTable() && $schemaSource === '*': $tables = $context->getStatement()->getJoinDefinition()->getTables(); if (count($tables) === 1) { foreach ($context->getCurrentSourceRow() as $alias => $columnData) { if (substr_count($alias, '.') === 0) { $resultRow[$alias] = $columnData; } } } else { foreach ($context->getCurrentSourceRow() as $alias => $columnData) { if (substr_count($alias, '.') === 1) { $resultRow[$alias] = $columnData; } } } break; case $resultColumn->getIsAllColumnsFromTable() && $schemaSource instanceof Table: $needleAlias = (string) $schemaSource; foreach ($context->getCurrentSourceRow() as $alias => $columnData) { if (substr($alias, 0, strlen($needleAlias)) === $needleAlias) { $columnName = substr($alias, strlen($needleAlias) + 1); $resultRow[$columnName] = $columnData; } } break; default: throw new \ErrorException("Invalid schema-source for result-specifier-column!"); } return $resultRow; }