Skip to content

Commit

Permalink
TASK: Migrate type:references earlier before Postprocessors
Browse files Browse the repository at this point in the history
That way the post processors are forced to be adjusted to work with the new format and will stop working for reference like property types

The inspector.dataTypes.references? configuration was removed as references are special types.
The `NodeReferenceConverter` was removed as it is out of use.
  • Loading branch information
mhsdesign committed Nov 16, 2023
1 parent 41b909b commit f636e2b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 109 deletions.
44 changes: 23 additions & 21 deletions Neos.ContentRepository.Core/Classes/NodeType/NodeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,29 @@ protected function buildFullConfiguration(): array
$this->fullConfiguration['childNodes'] = $sorter->toArray();
}

// migrate old property like references to references
$referencesConfiguration = $this->fullConfiguration['references'] ?? [];
foreach ($this->fullConfiguration['properties'] ?? [] as $propertyName => $propertyConfiguration) {
$propertyType = $propertyConfiguration['type'] ?? 'string';
switch ($propertyType) {
case 'reference':
unset($propertyConfiguration['type']);
$propertyConfiguration['constraints']['maxItems'] = 1;
// @deprecated remove with 10
// used to ensure that the FlowQuery property operation will return the node directly but not an array of nodes
$propertyConfiguration['__legacyPropertyType'] = 'reference';
$referencesConfiguration[$propertyName] = $propertyConfiguration;
unset($this->fullConfiguration['properties'][$propertyName]);
break;
case 'references':
unset($propertyConfiguration['type']);
$referencesConfiguration[$propertyName] = $propertyConfiguration;
unset($this->fullConfiguration['properties'][$propertyName]);
break;
}
}
$this->fullConfiguration['references'] = $referencesConfiguration;

return $this->fullConfiguration;
}

Expand Down Expand Up @@ -530,27 +553,6 @@ public function allowsChildNodeType(NodeType $nodeType): bool
*/
protected function setFullConfiguration(array $fullConfiguration): void
{
$referencesConfiguration = $fullConfiguration['references'] ?? [];
foreach ($fullConfiguration['properties'] ?? [] as $propertyName => $propertyConfiguration) {
$propertyType = $propertyConfiguration['type'] ?? 'string';
switch ($propertyType) {
case 'reference':
unset($propertyConfiguration['type']);
$propertyConfiguration['constraints']['maxItems'] = 1;
// @deprecated remove with 10
// used to ensure that the FlowQuery property operation will return the node directly but not an array of nodes
$propertyConfiguration['__legacyPropertyType'] = 'reference';
$referencesConfiguration[$propertyName] = $propertyConfiguration;
unset($fullConfiguration['properties'][$propertyName]);
break;
case 'references':
unset($propertyConfiguration['type']);
$referencesConfiguration[$propertyName] = $propertyConfiguration;
unset($fullConfiguration['properties'][$propertyName]);
break;
}
}
$fullConfiguration['references'] = $referencesConfiguration;
$this->fullConfiguration = $fullConfiguration;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,29 @@ class DefaultPropertyEditorPostprocessor implements NodeTypePostprocessorInterfa
public function process(NodeType $nodeType, array &$configuration, array $options): void
{
$nodeTypeName = $nodeType->name->value;

foreach ($configuration['references'] as $referenceName => &$referenceConfiguration) {
if (!isset($referenceConfiguration['ui']['inspector'])) {
// we presume that these are properties wich are not shown
continue;
}

$editor = $referenceConfiguration['ui']['inspector']['editor'] ?? null;

if (!$editor) {
$maxAllowedItems = $referenceConfiguration['constraints']['maxItems'] ?? null;
$editor = $maxAllowedItems === 1 ? 'Neos.Neos/Inspector/Editors/ReferenceEditor' : 'Neos.Neos/Inspector/Editors/ReferencesEditor';
}

$mergedInspectorConfiguration = $this->editorDefaultConfiguration[$editor] ?? [];
$mergedInspectorConfiguration = Arrays::arrayMergeRecursiveOverrule(
$mergedInspectorConfiguration,
$referenceConfiguration['ui']['inspector']
);
$referenceConfiguration['ui']['inspector'] = $mergedInspectorConfiguration;
$referenceConfiguration['ui']['inspector']['editor'] = $editor;
}

if (isset($configuration['properties']) && is_array($configuration['properties'])) {
foreach ($configuration['properties'] as $propertyName => &$propertyConfiguration) {
if (!isset($propertyConfiguration['type'])) {
Expand All @@ -57,6 +80,7 @@ public function process(NodeType $nodeType, array &$configuration, array $option
$type = $propertyConfiguration['type'];

if (!isset($propertyConfiguration['ui']['inspector'])) {
// we presume that these are properties wich are not shown
continue;
}

Expand Down
80 changes: 0 additions & 80 deletions Neos.Neos/Classes/Service/Mapping/NodeReferenceConverter.php

This file was deleted.

4 changes: 2 additions & 2 deletions Neos.Neos/Classes/Service/Mapping/NodeTypeStringConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
use Neos\ContentRepository\Core\NodeType\NodeType;

/**
* Convert a boolean to a JavaScript compatible string representation.
*
* @internal
* @deprecated todo still used?
* @Flow\Scope("singleton")
*/
class NodeTypeStringConverter extends AbstractTypeConverter
Expand Down
6 changes: 0 additions & 6 deletions Neos.Neos/Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,6 @@ Neos:
editor: Neos.Neos/Inspector/Editors/DateTimeEditor
editorOptions:
format: d-m-Y
reference:
typeConverter: Neos\Neos\Service\Mapping\NodeReferenceConverter
editor: Neos.Neos/Inspector/Editors/ReferenceEditor
references:
typeConverter: Neos\Neos\Service\Mapping\NodeReferenceConverter
editor: Neos.Neos/Inspector/Editors/ReferencesEditor
editors:
Neos.Neos/Inspector/Editors/CodeEditor:
editorOptions:
Expand Down

0 comments on commit f636e2b

Please sign in to comment.