Skip to content

Commit

Permalink
[TASK] Simplify isRelationField condition
Browse files Browse the repository at this point in the history
  • Loading branch information
nhovratov committed Mar 23, 2024
1 parent 9259cda commit 48eeacb
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions Classes/DataProcessing/ContentBlockDataDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private function buildContentBlockDataObjectRecursive(
continue;
}
$resolvedField = $resolvedRelation->resolved[$tcaFieldDefinition->getUniqueIdentifier()];
if ($this->isRelationField($resolvedField, $tcaFieldDefinition, $table)) {
if ($this->isRelationField($resolvedField)) {
$resolvedField = $this->handleRelation(
$resolvedRelation,
$tcaFieldDefinition,
Expand Down Expand Up @@ -131,23 +131,18 @@ private function handleRelation(
return $resolvedField;
}

private function isRelationField(mixed $resolvedField, TcaFieldDefinition $tcaFieldDefinition, string $table): bool
private function isRelationField(mixed $resolvedField): bool
{
if ($resolvedField instanceof ResolvedRelation) {
return true;
}
if (!is_array($resolvedField)) {
return false;
}
$fieldType = $tcaFieldDefinition->getFieldType();
$relationTcaTypes = ['inline', 'select', 'group'];
if (!in_array($fieldType::getTcaType(), $relationTcaTypes, true)) {
return false;
}
if ($this->getRelationTable($tcaFieldDefinition, $table) === '') {
return false;
if (($resolvedField[0] ?? null) instanceof ResolvedRelation) {
return true;
}
return true;
return false;
}

/**
Expand Down

0 comments on commit 48eeacb

Please sign in to comment.