Skip to content

Commit 80d919d

Browse files
committed
Merge pull request #60 from phpcr/list_accept_uuid
Node List accepts UUID
2 parents 138efa4 + 937b9de commit 80d919d

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ alpha-4
88

99
- [node] copy,move and clone - Target paths automatically append basename if target is a node.
1010
- [query] Always show path next to resultset
11+
- [node] `node:list` Enable listing nodes by UUID
1112

1213
### Bugs Fixes
1314

features/phpcr_node_list.feature

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Feature: List properites and chidren of current node
1+
Feature: List properites and chidren of current nodeA
22
In order to list the properties and children of the current node
33
As a user that is logged into the shell
44
I should be able to run a command which does that
@@ -60,3 +60,11 @@ Feature: List properites and chidren of current node
6060
"""
6161
| @* | nt:base | |
6262
"""
63+
64+
Scenario: List node by UUID
65+
Given I execute the "node:list 842e61c0-09ab-42a9-87c0-308ccc90e6f4" command
66+
Then the command should not fail
67+
And I should see the following:
68+
"""
69+
jcr:uuid
70+
"""

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Symfony\Component\Console\Input\InputArgument;
99
use Symfony\Component\Console\Input\InputOption;
1010
use PHPCR\PropertyType;
11+
use PHPCR\Util\UUIDHelper;
1112

1213
class NodeListCommand extends Command
1314
{
@@ -19,7 +20,7 @@ class NodeListCommand extends Command
1920
protected function configure()
2021
{
2122
$this->setName('node:list');
22-
$this->setDescription('List the children / properties of this node');
23+
$this->setDescription('List the children / properties of this node at the given path or with the given UUID');
2324
$this->addArgument('path', InputArgument::OPTIONAL, 'Path of node', '.');
2425
$this->addOption('children', null, InputOption::VALUE_NONE, 'List only the children of this node');
2526
$this->addOption('properties', null, InputOption::VALUE_NONE, 'List only the properties of this node');
@@ -33,6 +34,11 @@ protected function configure()
3334
3435
The <info>node:list</info> command can also shows template nodes and properties as defined a nodes node-type by
3536
using the <info>--template</info> option. Template nodes and properties are prefixed with the "@" symbol.
37+
38+
The command accepts wither a path (relative or absolute) to the node or a UUID.
39+
40+
PHPCRSH> node:list 842e61c0-09ab-42a9-87c0-308ccc90e6f4
41+
PHPCRSH> node:list /tests/foobar
3642
HERE
3743
);
3844
}
@@ -50,8 +56,14 @@ public function execute(InputInterface $input, OutputInterface $output)
5056

5157
$session = $this->getHelper('phpcr')->getSession();
5258

53-
$path = $session->getAbsPath($input->getArgument('path'));
54-
$currentNode = $session->getNode($path);
59+
$path = $input->getArgument('path');
60+
61+
if (true === UUIDHelper::isUUID($path)) {
62+
$currentNode = $session->getNodeByIdentifier($path);
63+
} else {
64+
$path = $session->getAbsPath($path);
65+
$currentNode = $session->getNode($path);
66+
}
5567

5668
if (!$this->showChildren && !$this->showProperties) {
5769
$this->showChildren = true;

0 commit comments

Comments
 (0)