Skip to content

Commit efe55ee

Browse files
committed
[WIP] fix issues after merge contribution
1 parent 030a3c2 commit efe55ee

18 files changed

Lines changed: 33 additions & 20 deletions

Build/JsonSchema/SchemaSources/FieldTypes/collection.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
"l10n_mode": {},
1616
"l10n_display": {},
1717
"exclude": {},
18-
"title": {
19-
"type": "string",
20-
"description": "Alternative title for Collection in Record Permissions view. Defaults to label."
21-
},
18+
"title": {
19+
"type": "string",
20+
"description": "Alternative title for Collection in Record Permissions view. Defaults to label."
21+
},
2222
"table": {
2323
"type": "string",
2424
"description": "The custom table name to be used for the new Record Type."

Classes/Definition/ContentType/ContentElementDefinition.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function __construct(
4545
public string $package,
4646
public int $priority,
4747
public ContentTypeIcon $typeIcon,
48+
public bool $hasExplicitCollectionTitle,
4849
public string $languagePathLabel,
4950
public string $languagePathTitle,
5051
public string $languagePathDescription,

Classes/Definition/ContentType/ContentTypeDefinition.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ public function getTypeIcon(): ContentTypeIcon
106106
return $this->typeIcon;
107107
}
108108

109+
public function hasExplicitCollectionTitle(): bool
110+
{
111+
return $this->hasExplicitCollectionTitle;
112+
}
113+
109114
public function getLanguagePathLabel(): string
110115
{
111116
return $this->languagePathLabel;

Classes/Definition/ContentType/ContentTypeInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function hasColumn(string $column): bool;
4141
/** @return string[] */
4242
public function getColumns(): array;
4343
public function getTypeIcon(): ContentTypeIcon;
44+
public function hasExplicitCollectionTitle(): bool;
4445
public function getLanguagePathLabel(): string;
4546
public function getLanguagePathTitle(): string;
4647
public function getLanguagePathDescription(): string;

Classes/Definition/ContentType/PageTypeDefinition.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function __construct(
4545
public string $package,
4646
public int $priority,
4747
public ContentTypeIcon $typeIcon,
48+
public bool $hasExplicitCollectionTitle,
4849
public string $languagePathLabel,
4950
public string $languagePathTitle,
5051
public string $languagePathDescription,

Classes/Definition/ContentType/RecordTypeDefinition.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function __construct(
4545
public string $package,
4646
public int $priority,
4747
public ContentTypeIcon $typeIcon,
48+
public bool $hasExplicitCollectionTitle,
4849
public string $languagePathLabel,
4950
public string $languagePathTitle,
5051
public string $languagePathDescription,

Classes/Definition/Factory/ContentBlockCompiler.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,11 @@ private function initializeContentTypeLabelAndDescription(
284284
$languagePathLabel = $languagePathTitle . '.label';
285285
$languagePathTitle = $languagePathTitle . '.title';
286286
$languagePathDescription = $languagePathDescription . '.description';
287-
$result->contentType->title = $title;
287+
// A Collection defining "title" must not be overwritten by the field label.
288+
$result->contentType->hasExplicitCollectionTitle = $title !== '';
289+
// Without an explicit title, the field label is the title of the Collection's table.
290+
// $title itself stays empty, so no automatic language key is generated for it.
291+
$result->contentType->title = $title !== '' ? $title : (string)($input->yaml['label'] ?? '');
288292
$result->contentType->description = $description;
289293
}
290294
$languagePathSource = new AutomaticLanguageSource($languagePathTitle, $title);
@@ -399,11 +403,6 @@ private function getFieldLabelPath(LanguagePath $languagePath): string
399403
return $languagePath->getCurrentPath() . '.label';
400404
}
401405

402-
private function getFieldTitlePath(LanguagePath $languagePath): string
403-
{
404-
return $languagePath->getCurrentPath() . '.title';
405-
}
406-
407406
private function getFieldDescriptionPath(LanguagePath $languagePath): string
408407
{
409408
return $languagePath->getCurrentPath() . '.description';
@@ -664,10 +663,6 @@ private function processCollection(ProcessingInput $input, ProcessedFieldsResult
664663
// Disable sorting as it is already handled in MM table.
665664
$field['sortable'] = false;
666665
}
667-
// The Collection's title equals the field label.
668-
if (!isset($field['title'])) {
669-
$field['title'] = $field['label'];
670-
}
671666
// Anonymous Collections can't have a type field.
672667
$field['typeField'] = null;
673668
$newInput = new ProcessingInput(

Classes/Definition/Factory/ContentTypeFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ private function prepareCommonArguments(array $typeDefinition): array
9696
$arguments['package'] = $typeDefinition['package'] ?? '';
9797
$arguments['priority'] = $typeDefinition['priority'] ?? 0;
9898
$arguments['typeIcon'] = ContentTypeIcon::fromArray($typeDefinition['typeIcon'] ?? []);
99+
$arguments['hasExplicitCollectionTitle'] = $typeDefinition['hasExplicitCollectionTitle'] ?? false;
99100
$arguments['languagePathLabel'] = $typeDefinition['languagePathLabel'] ?? '';
100101
$arguments['languagePathTitle'] = $typeDefinition['languagePathTitle'] ?? null;
101102
$arguments['languagePathDescription'] = $typeDefinition['languagePathDescription'] ?? null;

Classes/Definition/Factory/Processing/ProcessedContentType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ final class ProcessedContentType
4242
/** @var array<TcaFieldDefinition> */
4343
public array $overrideColumns = [];
4444
public string|int $typeName = '';
45+
public bool $hasExplicitCollectionTitle = false;
4546
public string $languagePathLabel = '';
4647
public string $languagePathTitle = '';
4748
public string $languagePathDescription = '';
@@ -61,6 +62,7 @@ public function toArray(bool $isRootTable, string $identifier, array $processedR
6162
'vendor' => $vendor,
6263
'package' => $package,
6364
'typeName' => $this->typeName,
65+
'hasExplicitCollectionTitle' => $this->hasExplicitCollectionTitle,
6466
'languagePathLabel' => $this->languagePathLabel,
6567
'languagePathTitle' => $this->languagePathTitle,
6668
'languagePathDescription' => $this->languagePathDescription,

Classes/Generator/TcaGenerator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,7 @@ protected function generateBaseTableTca(TableDefinition $tableDefinition): array
978978
$title = $defaultTypeDefinition->getTitle();
979979
$languagePathTitle = $defaultTypeDefinition->getLanguagePathTitle();
980980
$languagePathLabel = $defaultTypeDefinition->getLanguagePathLabel();
981-
$hasExplicitCollectionTitle = $languagePathTitle !== $languagePathLabel && $title !== '';
982-
if (!$hasExplicitCollectionTitle) {
981+
if (!$defaultTypeDefinition->hasExplicitCollectionTitle()) {
983982
if ($this->languageFileRegistry->isset($defaultTypeDefinition->getName(), $languagePathTitle)) {
984983
$title = $languagePathTitle;
985984
} elseif ($this->languageFileRegistry->isset($defaultTypeDefinition->getName(), $languagePathLabel)) {

0 commit comments

Comments
 (0)