diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c43a6d3..9436ef2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Changelog dev-master ---------- +- [references] Show UUIDs when listing reference properties - [transport] Added transport layer for experimental Jackalope FS implementation - [misc] Wildcard (single asterisk) support in paths - [node] Added wilcard support to applicable node commands, including "node:list", "node:remove" and "node:property:show" diff --git a/features/all/phpcr_node_references.feature b/features/all/phpcr_node_references.feature index 560ce6c6..a4e182f9 100644 --- a/features/all/phpcr_node_references.feature +++ b/features/all/phpcr_node_references.feature @@ -12,24 +12,24 @@ Feature: Show node references And I execute the "node:references . --no-ansi" command Then the command should not fail And I should see a table containing the following rows: - | Type | Property | Node Path | - | weak | ref2 | /tests_general_base/idExample/jcr:content/weakreference_source2 | - | weak | ref1 | /tests_general_base/idExample/jcr:content/weakreference_source1 | + | Path | Property | Type | + | /tests_general_base/idExample/jcr:content/weakreference_source1 |ref1 | weak | + | /tests_general_base/idExample/jcr:content/weakreference_source2 |ref2 | weak | Scenario: List named weak references Given the current node is "/tests_general_base/idExample/jcr:content/weakreference_target" And I execute the "node:references . ref2 --no-ansi" command Then the command should not fail And I should see a table containing the following rows: - | Type | Property | Node Path | - | weak | ref2 | /tests_general_base/idExample/jcr:content/weakreference_source2 | + | Path | Property | Type | + | /tests_general_base/idExample/jcr:content/weakreference_source2 |ref2 | weak | Scenario: List strong references Given the current node is "/tests_general_base/idExample" And I execute the "node:references . --no-ansi" command Then the command should not fail And I should see a table containing the following rows: - | Type | Property | Node Path | - | strong | ref | /tests_general_base/numberPropertyNode/jcr:content | - | strong | multiref | /tests_general_base/numberPropertyNode/jcr:content | + | Path | Property | Type | + | /tests_general_base/numberPropertyNode/jcr:content | multiref | strong | + | /tests_general_base/numberPropertyNode/jcr:content | ref | strong | diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php index 636585ab..f13da5fa 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php @@ -56,7 +56,7 @@ public function execute(InputInterface $input, OutputInterface $output) $table = $this->get('helper.table')->create(); $table->setHeaders(array( - 'Type', 'Property', 'Node Path' + 'Path', 'Property', 'Type', )); foreach ($references as $type => $typeReferences) { @@ -64,9 +64,9 @@ public function execute(InputInterface $input, OutputInterface $output) $nodePath = $property->getParent()->getPath(); $table->addRow(array( - $type, + $nodePath, $property->getName(), - $nodePath + $type, )); } } diff --git a/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php b/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php index 3fe28243..d45eb67b 100644 --- a/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php +++ b/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php @@ -54,21 +54,19 @@ public function getPropertyTypeName($typeInteger) */ public function formatQueryResult(QueryResultInterface $result, OutputInterface $output, $elapsed) { - $selectorNames = $result->getSelectorNames(); - $table = $this->tableHelper->create(); $table->setHeaders(array_merge(array( 'Path', 'Index', ), $result->getColumnNames())); - foreach ($result->getRows() as $i => $row) { + foreach ($result->getRows() as $row) { $values = array_merge(array( $row->getPath(), $row->getNode()->getIndex(), ), $row->getValues()); - foreach ($values as $columnName => &$value) { + foreach ($values as &$value) { $value = $this->normalizeValue($value); } @@ -90,13 +88,17 @@ public function normalizeValue($value) foreach ($array as $i => $value) { if ($value instanceof NodeInterface) { + $uuid = $value->getIdentifier(); $value = $value->getPath(); + if ($uuid) { + $value .= ' (' . $uuid . ')'; + } } elseif (is_object($value)) { $value = ''; } else { $value = $value; } - $value = '[' . $i . '] ' . $this->textHelper->truncate($value); + $value = '[' . $i . '] ' . $this->textHelper->truncate($value, 255); $values[] = $value; } @@ -112,10 +114,8 @@ public function normalizeValue($value) public function formatValue(PropertyInterface $value, $showBinary = false) { - $v = $value->getValue(); - - if (is_array($v)) { - return $this->normalizeValue($v); + if (is_array($value->getValue())) { + return $this->normalizeValue($value->getValue()); } switch (intval($value->getType())) {