Skip to content

Commit 3b4823c

Browse files
committed
Merge pull request #120 from phpcr/show_uuid_reference
Show UUID's in references
2 parents 2188e6e + 887bdb4 commit 3b4823c

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
dev-master
55
----------
66

7+
- [references] Show UUIDs when listing reference properties
78
- [transport] Added transport layer for experimental Jackalope FS implementation
89
- [misc] Wildcard (single asterisk) support in paths
910
- [node] Added wilcard support to applicable node commands, including "node:list", "node:remove" and "node:property:show"

features/all/phpcr_node_references.feature

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ Feature: Show node references
1212
And I execute the "node:references . --no-ansi" command
1313
Then the command should not fail
1414
And I should see a table containing the following rows:
15-
| Type | Property | Node Path |
16-
| weak | ref2 | /tests_general_base/idExample/jcr:content/weakreference_source2 |
17-
| weak | ref1 | /tests_general_base/idExample/jcr:content/weakreference_source1 |
15+
| Path | Property | Type |
16+
| /tests_general_base/idExample/jcr:content/weakreference_source1 |ref1 | weak |
17+
| /tests_general_base/idExample/jcr:content/weakreference_source2 |ref2 | weak |
1818

1919
Scenario: List named weak references
2020
Given the current node is "/tests_general_base/idExample/jcr:content/weakreference_target"
2121
And I execute the "node:references . ref2 --no-ansi" command
2222
Then the command should not fail
2323
And I should see a table containing the following rows:
24-
| Type | Property | Node Path |
25-
| weak | ref2 | /tests_general_base/idExample/jcr:content/weakreference_source2 |
24+
| Path | Property | Type |
25+
| /tests_general_base/idExample/jcr:content/weakreference_source2 |ref2 | weak |
2626

2727
Scenario: List strong references
2828
Given the current node is "/tests_general_base/idExample"
2929
And I execute the "node:references . --no-ansi" command
3030
Then the command should not fail
3131
And I should see a table containing the following rows:
32-
| Type | Property | Node Path |
33-
| strong | ref | /tests_general_base/numberPropertyNode/jcr:content |
34-
| strong | multiref | /tests_general_base/numberPropertyNode/jcr:content |
32+
| Path | Property | Type |
33+
| /tests_general_base/numberPropertyNode/jcr:content | multiref | strong |
34+
| /tests_general_base/numberPropertyNode/jcr:content | ref | strong |
3535

src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ public function execute(InputInterface $input, OutputInterface $output)
5656

5757
$table = $this->get('helper.table')->create();
5858
$table->setHeaders(array(
59-
'Type', 'Property', 'Node Path'
59+
'Path', 'Property', 'Type',
6060
));
6161

6262
foreach ($references as $type => $typeReferences) {
6363
foreach ($typeReferences as $property) {
6464
$nodePath = $property->getParent()->getPath();
6565

6666
$table->addRow(array(
67-
$type,
67+
$nodePath,
6868
$property->getName(),
69-
$nodePath
69+
$type,
7070
));
7171
}
7272
}

src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,19 @@ public function getPropertyTypeName($typeInteger)
5454
*/
5555
public function formatQueryResult(QueryResultInterface $result, OutputInterface $output, $elapsed)
5656
{
57-
$selectorNames = $result->getSelectorNames();
58-
5957
$table = $this->tableHelper->create();
6058
$table->setHeaders(array_merge(array(
6159
'Path',
6260
'Index',
6361
), $result->getColumnNames()));
6462

65-
foreach ($result->getRows() as $i => $row) {
63+
foreach ($result->getRows() as $row) {
6664
$values = array_merge(array(
6765
$row->getPath(),
6866
$row->getNode()->getIndex(),
6967
), $row->getValues());
7068

71-
foreach ($values as $columnName => &$value) {
69+
foreach ($values as &$value) {
7270
$value = $this->normalizeValue($value);
7371
}
7472

@@ -90,13 +88,17 @@ public function normalizeValue($value)
9088

9189
foreach ($array as $i => $value) {
9290
if ($value instanceof NodeInterface) {
91+
$uuid = $value->getIdentifier();
9392
$value = $value->getPath();
93+
if ($uuid) {
94+
$value .= ' (' . $uuid . ')';
95+
}
9496
} elseif (is_object($value)) {
9597
$value = '<UNKNOWN OBJECT>';
9698
} else {
9799
$value = $value;
98100
}
99-
$value = '[' . $i . '] ' . $this->textHelper->truncate($value);
101+
$value = '[' . $i . '] ' . $this->textHelper->truncate($value, 255);
100102
$values[] = $value;
101103
}
102104

@@ -112,10 +114,8 @@ public function normalizeValue($value)
112114

113115
public function formatValue(PropertyInterface $value, $showBinary = false)
114116
{
115-
$v = $value->getValue();
116-
117-
if (is_array($v)) {
118-
return $this->normalizeValue($v);
117+
if (is_array($value->getValue())) {
118+
return $this->normalizeValue($value->getValue());
119119
}
120120

121121
switch (intval($value->getType())) {

0 commit comments

Comments
 (0)