diff --git a/Neos.ContentRepository/Classes/Command/NodeTypesCommandController.php b/Neos.ContentRepository/Classes/Command/NodeTypesCommandController.php
index 9460c8ab2f3..65d05f57711 100644
--- a/Neos.ContentRepository/Classes/Command/NodeTypesCommandController.php
+++ b/Neos.ContentRepository/Classes/Command/NodeTypesCommandController.php
@@ -27,22 +27,30 @@ class NodeTypesCommandController extends CommandController
* Shows the merged configuration (including supertypes) of a NodeType
*
* @param string $nodeTypeName The name of the NodeType to show
- * @param ?string $path Path of the NodeType-configuration which will be shown
+ * @param string $path Path of the NodeType-configuration which will be shown
+ * @param int $level Truncate the configuration at this depth and show '...' (Usefully for only seeing the keys of the properties)
*/
- public function showCommand(string $nodeTypeName, ?string $path = null): void
+ public function showCommand(string $nodeTypeName, string $path = '', int $level = 0): void
{
+ if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) {
+ $this->outputLine('NodeType "%s" was not found!', [$nodeTypeName]);
+ $this->quit();
+ }
+
$nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName);
- if (!$nodeType) {
- $this->outputLine('NodeType "%s" was not found!', [$nodeTypeName]);
+
+ if ($path && !$nodeType->hasConfiguration($path)) {
+ $this->outputLine('NodeType "%s" does not have configuration "%s".', [$nodeTypeName, $path]);
$this->quit();
}
- $yaml = Yaml::dump(
- $path
- ? $nodeType->getConfiguration($path)
- : [$nodeTypeName => $nodeType->getFullConfiguration()],
- 99
- );
- $this->outputLine('NodeType Configuration "%s":', [$nodeTypeName . ($path ? ("." . $path) : "")]);
+
+ $configuration = $path
+ ? self::truncateArrayAtLevel($nodeType->getConfiguration($path), $level)
+ : [$nodeTypeName => self::truncateArrayAtLevel($nodeType->getFullConfiguration(), $level)];
+
+ $yaml = Yaml::dump($configuration, 99);
+
+ $this->outputLine('NodeType configuration "%s":', [$nodeTypeName . ($path ? ("." . $path) : "")]);
$this->outputLine();
$this->outputLine($yaml);
$this->outputLine();
@@ -78,4 +86,28 @@ public function listCommand(?string $filter = null, bool $includeAbstract = true
}
}
}
+
+ /**
+ * @param int $truncateLevel 0 for no truncation and 1 to only show the first keys of the array
+ * @param int $currentLevel 1 for the start and will be incremented recursively
+ */
+ private static function truncateArrayAtLevel(array $array, int $truncateLevel, int $currentLevel = 1): array
+ {
+ if ($truncateLevel <= 0) {
+ return $array;
+ }
+ $truncatedArray = [];
+ foreach ($array as $key => $value) {
+ if ($currentLevel >= $truncateLevel) {
+ $truncatedArray[$key] = '...'; // truncated
+ continue;
+ }
+ if (!is_array($value)) {
+ $truncatedArray[$key] = $value;
+ continue;
+ }
+ $truncatedArray[$key] = self::truncateArrayAtLevel($value, $truncateLevel, $currentLevel + 1);
+ }
+ return $truncatedArray;
+ }
}