|
8 | 8 | use Symfony\Component\Console\Input\InputArgument;
|
9 | 9 | use Symfony\Component\Console\Input\InputOption;
|
10 | 10 | use PHPCR\PropertyType;
|
| 11 | +use PHPCR\ItemNotFoundException; |
| 12 | +use PHPCR\PropertyInterface; |
| 13 | +use PHPCR\NodeInterface; |
11 | 14 |
|
12 | 15 | class NodeListCommand extends Command
|
13 | 16 | {
|
@@ -99,12 +102,24 @@ private function renderChildren($currentNode, $table, $spacers)
|
99 | 102 | unset($childNodeNames[$child->getName()]);
|
100 | 103 | }
|
101 | 104 |
|
| 105 | + $primaryItemValue = ''; |
| 106 | + try { |
| 107 | + $primaryItem = $child->getPrimaryItem(); |
| 108 | + |
| 109 | + if ($primaryItem instanceof PropertyInterface) { |
| 110 | + $primaryItemValue = $this->textHelper->truncate($this->formatter->formatValue($primaryItem), 55); |
| 111 | + } elseif ($primaryItem instanceof NodeInterface) { |
| 112 | + $primaryItemValue = sprintf('+%s', $primaryItem->getName()); |
| 113 | + } |
| 114 | + } catch (ItemNotFoundException $e) { |
| 115 | + } |
| 116 | + |
102 | 117 | $isLast = count($children) === $i;
|
103 | 118 |
|
104 | 119 | $table->addRow(array(
|
105 | 120 | '<node>' . implode('', $spacers) . $this->formatter->formatNodeName($child) . '</node>',
|
106 | 121 | $child->getPrimaryNodeType()->getName(),
|
107 |
| - '', |
| 122 | + $primaryItemValue, |
108 | 123 | ));
|
109 | 124 |
|
110 | 125 | if (count($spacers) < $this->maxLevel) {
|
@@ -136,6 +151,12 @@ private function renderProperties($currentNode, $table, $spacers)
|
136 | 151 | {
|
137 | 152 | $properties = $currentNode->getProperties($this->filters ? : null);
|
138 | 153 |
|
| 154 | + try { |
| 155 | + $primaryItem = $currentNode->getPrimaryItem(); |
| 156 | + } catch (ItemNotFoundException $e) { |
| 157 | + $primaryItem = null; |
| 158 | + } |
| 159 | + |
139 | 160 | $nodeType = $currentNode->getPrimaryNodeType();
|
140 | 161 | $propertyDefinitions = $nodeType->getDeclaredPropertyDefinitions();
|
141 | 162 |
|
|
0 commit comments