Skip to content
Snippets Groups Projects
Commit 8f070716 authored by Nikita Hovratov's avatar Nikita Hovratov Committed by Oliver Bartsch
Browse files

[TASK] Reduce hard-coded `tt_content` table in StandardPreviewRenderer

The goal here is to have a generic PreviewRenderer, which is not
tt_content specific. The StandardContentPreviewRenderer could then
extend this generic renderer. This is a pre-patch to make the
refactoring easier in the next patch.

For this to work, GridColumnItem now exposes methods to retrieve the
table from the context, the type column and the record type.

Additionally, some drive-by refactorings have been done like early
return statements and stricter checks.

The unused variable $infoArr has been removed as well.

Resolves: #102825
Releases: main, 12.4
Change-Id: I38eab3c095e06b789915600e79b7831556a25ca5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84705


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: default avatarOliver Bartsch <bo@cedev.de>
parent 54f422bd
Branches
Tags
No related merge requests found
......@@ -168,10 +168,12 @@ class GridColumnItem extends AbstractGridObject
if (($typeColumn = $this->getTypeColumn()) === '') {
return '';
}
$contentType = $this->record[$typeColumn] ?? '';
if (($recordType = $this->getRecordType()) === '') {
return '';
}
$contentTypeLabels = $this->context->getContentTypeLabels();
return $contentTypeLabels[$contentType] ??
BackendUtility::getLabelFromItemListMerged((int)($this->record['pid'] ?? 0), $this->table, $typeColumn, $contentType, $this->record);
return $contentTypeLabels[$recordType] ??
BackendUtility::getLabelFromItemListMerged((int)($this->record['pid'] ?? 0), $this->table, $typeColumn, $recordType, $this->record);
}
public function getIcons(): string
......@@ -351,6 +353,21 @@ class GridColumnItem extends AbstractGridObject
return $uriBuilder->buildUriFromRoute('record_edit', $urlParameters) . '#element-' . $this->table . '-' . $this->record['uid'];
}
public function getTypeColumn(): string
{
return (string)($GLOBALS['TCA'][$this->table]['ctrl']['type'] ?? '');
}
public function getRecordType(): string
{
return (string)($this->record[$this->getTypeColumn()] ?? '');
}
public function getTable(): string
{
return $this->table;
}
/**
* Gets the number of records referencing the record with the UID $uid in
* the current table.
......@@ -361,9 +378,4 @@ class GridColumnItem extends AbstractGridObject
{
return GeneralUtility::makeInstance(ReferenceIndex::class)->getNumberOfReferencedRecords($this->table, $uid);
}
protected function getTypeColumn(): string
{
return (string)($GLOBALS['TCA'][$this->table]['ctrl']['type'] ?? '');
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment