diff --git a/CHANGELOG.md b/CHANGELOG.md index bc469e10..06d8b0f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ alpha-4 - [node] copy,move and clone - Target paths automatically append basename if target is a node. - [query] Always show path next to resultset - [node|shell] Most commands which accept a node path can also accept a UUID +- [node] `node:list`: Show node primary item value ### Bugs Fixes diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php index bfda064a..9d34e1c1 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php @@ -8,6 +8,9 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use PHPCR\PropertyType; +use PHPCR\ItemNotFoundException; +use PHPCR\PropertyInterface; +use PHPCR\NodeInterface; class NodeListCommand extends Command { @@ -99,12 +102,24 @@ private function renderChildren($currentNode, $table, $spacers) unset($childNodeNames[$child->getName()]); } + $primaryItemValue = ''; + try { + $primaryItem = $child->getPrimaryItem(); + + if ($primaryItem instanceof PropertyInterface) { + $primaryItemValue = $this->textHelper->truncate($this->formatter->formatValue($primaryItem), 55); + } elseif ($primaryItem instanceof NodeInterface) { + $primaryItemValue = sprintf('+%s', $primaryItem->getName()); + } + } catch (ItemNotFoundException $e) { + } + $isLast = count($children) === $i; $table->addRow(array( '' . implode('', $spacers) . $this->formatter->formatNodeName($child) . '', $child->getPrimaryNodeType()->getName(), - '', + $primaryItemValue, )); if (count($spacers) < $this->maxLevel) { @@ -136,6 +151,12 @@ private function renderProperties($currentNode, $table, $spacers) { $properties = $currentNode->getProperties($this->filters ? : null); + try { + $primaryItem = $currentNode->getPrimaryItem(); + } catch (ItemNotFoundException $e) { + $primaryItem = null; + } + $nodeType = $currentNode->getPrimaryNodeType(); $propertyDefinitions = $nodeType->getDeclaredPropertyDefinitions();