Skip to content

Commit

Permalink
FEATURE: NodeType allow unsetting inherited properties
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Oct 14, 2023
1 parent f51830a commit f016f45
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
5 changes: 5 additions & 0 deletions Neos.ContentRepository.Core/Classes/NodeType/NodeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ protected function buildFullConfiguration(): array
}
$this->fullConfiguration = Arrays::arrayMergeRecursiveOverrule($mergedConfiguration, $this->localConfiguration);

// Remove unset properties
$this->fullConfiguration['properties'] = array_filter($this->fullConfiguration['properties'], function ($propertyConfiguration) {
return $propertyConfiguration !== null;
});

if (
isset($this->fullConfiguration['childNodes'])
&& is_array($this->fullConfiguration['childNodes'])
Expand Down
14 changes: 0 additions & 14 deletions Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,6 @@ protected function loadNodeType(string $nodeTypeName, array &$completeNodeTypeCo
);
}

// Remove unset properties
$properties = [];
if (isset($nodeTypeConfiguration['properties']) && is_array($nodeTypeConfiguration['properties'])) {
$properties = $nodeTypeConfiguration['properties'];
}

$nodeTypeConfiguration['properties'] = array_filter($properties, function ($propertyConfiguration) {
return $propertyConfiguration !== null;
});

if ($nodeTypeConfiguration['properties'] === []) {
unset($nodeTypeConfiguration['properties']);
}

$nodeType = new NodeType(
NodeTypeName::fromString($nodeTypeName),
$superTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,24 @@ public function showCommand(string $nodeTypeName, ?string $path = null, string $
$nodeTypeManager = $this->contentRepositoryRegistry->get($contentRepositoryId)->getNodeTypeManager();

if (!$nodeTypeManager->hasNodeType($nodeTypeName)) {
$this->outputLine('<b>NodeType "%s" was not found!</b>', [$nodeTypeName]);
$this->outputLine('<error>NodeType "%s" was not found!</error>', [$nodeTypeName]);
$this->quit();
}

$nodeType = $nodeTypeManager->getNodeType($nodeTypeName);

if ($path && !$nodeType->hasConfiguration($path)) {
$this->outputLine('<b>NodeType "%s" does not have configuration "%s".</b>', [$nodeTypeName, $path]);
$this->quit();
}

$yaml = Yaml::dump(
$path
? $nodeType->getConfiguration($path)
: [$nodeTypeName => $nodeType->getFullConfiguration()],
99
);
$this->outputLine('<b>NodeType Configuration "%s":</b>', [$nodeTypeName . ($path ? ("." . $path) : "")]);
$this->outputLine('<b>NodeType configuration "%s":</b>', [$nodeTypeName . ($path ? ("." . $path) : "")]);
$this->outputLine();
$this->outputLine($yaml);
$this->outputLine();
Expand Down

0 comments on commit f016f45

Please sign in to comment.