8
8
use Symfony \Component \Console \Input \InputArgument ;
9
9
use Symfony \Component \Console \Input \InputOption ;
10
10
use PHPCR \PropertyType ;
11
+ use PHPCR \Util \UUIDHelper ;
11
12
12
13
class NodeListCommand extends Command
13
14
{
@@ -19,7 +20,7 @@ class NodeListCommand extends Command
19
20
protected function configure ()
20
21
{
21
22
$ 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 ' );
23
24
$ this ->addArgument ('path ' , InputArgument::OPTIONAL , 'Path of node ' , '. ' );
24
25
$ this ->addOption ('children ' , null , InputOption::VALUE_NONE , 'List only the children of this node ' );
25
26
$ this ->addOption ('properties ' , null , InputOption::VALUE_NONE , 'List only the properties of this node ' );
@@ -33,6 +34,11 @@ protected function configure()
33
34
34
35
The <info>node:list</info> command can also shows template nodes and properties as defined a nodes node-type by
35
36
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
36
42
HERE
37
43
);
38
44
}
@@ -50,8 +56,14 @@ public function execute(InputInterface $input, OutputInterface $output)
50
56
51
57
$ session = $ this ->getHelper ('phpcr ' )->getSession ();
52
58
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
+ }
55
67
56
68
if (!$ this ->showChildren && !$ this ->showProperties ) {
57
69
$ this ->showChildren = true ;
0 commit comments