Skip to content

Commit

Permalink
Update DatabaseQueryProcessor.php
Browse files Browse the repository at this point in the history
This makes it possible, to configure only one field of the result.
We have a link field, which wasn't parsed as typolink. But we didn't want to define every single field of the query. So we added the key "overrideFields".
e.g.:

20 = FriendsOfTYPO3Headless\HeadlessBootstrapPackage\DataProcessing\DatabaseQueryProcessor
20 {
  table = tx_bootstrappackage_carousel_item
  pidInList.field = pid
  where {
    data = field:uid
    intval = 1
    wrap = tt_content=|
  }
  overrideFields {
    link = TEXT
    link {
      field = link
      htmlSpecialChars = 1
      typolink {
        parameter {
          field = link
        }
        returnLast = result
      }
    }
  }
  orderBy = sorting
  as = records
}
  • Loading branch information
derseeli authored Feb 7, 2022
1 parent 73b0076 commit bf8da47
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Classes/DataProcessing/DatabaseQueryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ private function processRecordVariables(array $records, string $tableName, array

$processedRecordVariables[$key] = $record;
$processedRecordVariables[$key] = $this->contentDataProcessor->process($recordContentObjectRenderer, $processorConfiguration, $processedRecordVariables[$key]);

if (isset($processorConfiguration['overrideFields.'])) {
$overrideFields = $this->typoScriptService->convertTypoScriptArrayToPlainArray($processorConfiguration['overrideFields.']);
$jsonCE = $this->typoScriptService->convertPlainArrayToTypoScriptArray(['fields' => $overrideFields, '_typoScriptNodeValue' => 'JSON']);
$record = \json_decode($recordContentObjectRenderer->cObjGetSingle('JSON', $jsonCE), true);

foreach ($record as $fieldName => $overrideData) {
$processedRecordVariables[$key][$fieldName] = $overrideData;
}
}
}

return $processedRecordVariables;
Expand Down

0 comments on commit bf8da47

Please sign in to comment.