Skip to content

Fixed behavior of node:references #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

dev-master
----------

- [node:references] Shows the referencing node paths instead of the referrered-to node path(s)

alpha-6
-------

Expand Down
12 changes: 6 additions & 6 deletions features/phpcr_node_references.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ Feature: Show node references
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_target |
| weak | ref1 | /tests_general_base/idExample/jcr:content/weakreference_target |
| weak | ref2 | /tests_general_base/idExample/jcr:content/weakreference_source2 |
| weak | ref1 | /tests_general_base/idExample/jcr:content/weakreference_source1 |

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_target |
| weak | ref2 | /tests_general_base/idExample/jcr:content/weakreference_source2 |

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/idExample |
| strong | multiref | /tests_general_base/idExample |
| | | /tests_general_base/multiValueProperty |
| strong | ref | /tests_general_base/numberPropertyNode/jcr:content |
| strong | multiref | /tests_general_base/numberPropertyNode/jcr:content |

14 changes: 2 additions & 12 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,12 @@ public function execute(InputInterface $input, OutputInterface $output)

foreach ($references as $type => $typeReferences) {
foreach ($typeReferences as $property) {
if ($property->isMultiple()) {
$nodes = $property->getNode();
} else {
$nodes = array($property->getNode());
}

$nodePaths = array();

foreach ($nodes as $node) {
$nodePaths[] = $node->getPath();
}
$nodePath = $property->getParent()->getPath();

$table->addRow(array(
$type,
$property->getName(),
implode("\n", $nodePaths),
$nodePath
));
}
}
Expand Down