@@ -14,7 +14,11 @@ protected function configure()
1414 $ this ->setDescription ('Show information about the current node ' );
1515 $ this ->addArgument ('path ' , InputArgument::REQUIRED , 'Path of node ' );
1616 $ this ->setHelp (<<<HERE
17- Show information about the current node
17+ Show information about the node(s) at the given path:
18+
19+ PHPCRSH> node:info path/to/node
20+
21+ The path can include wildcards.
1822HERE
1923 );
2024 }
@@ -24,48 +28,51 @@ public function execute(InputInterface $input, OutputInterface $output)
2428 $ session = $ this ->get ('phpcr.session ' );
2529 $ path = $ input ->getArgument ('path ' );
2630 $ nodeHelper = $ this ->get ('helper.node ' );
27- $ currentNode = $ session ->getNodeByPathOrIdentifier ($ path );
2831 $ formatter = $ this ->get ('helper.result_formatter ' );
2932
30- $ mixins = $ currentNode ->getMixinNodeTypes ();
31- $ mixinNodeTypeNames = array ();
33+ $ nodes = $ session ->findNodes ($ path );
3234
33- foreach ($ mixins as $ name => $ mixin ) {
34- $ mixinNodeTypeNames [] = $ mixin ->getName ();
35- }
35+ foreach ($ nodes as $ node ) {
36+ $ mixins = $ node ->getMixinNodeTypes ();
37+ $ mixinNodeTypeNames = array ();
38+
39+ foreach ($ mixins as $ mixin ) {
40+ $ mixinNodeTypeNames [] = $ mixin ->getName ();
41+ }
42+
43+ if ($ nodeHelper ->nodeHasMixinType ($ node , 'mix:versionable ' )) {
44+ try {
45+ $ isCheckedOut = $ node ->isCheckedOut () ? 'yes ' : 'no ' ;
46+ } catch (\Exception $ e ) {
47+ $ isCheckedOut = $ formatter ->formatException ($ e );
48+ }
49+ } else {
50+ $ isCheckedOut = 'N/A ' ;
51+ }
3652
37- if ($ nodeHelper ->nodeHasMixinType ($ currentNode , 'mix:versionable ' )) {
3853 try {
39- $ isCheckedOut = $ currentNode -> isCheckedOut () ? 'yes ' : 'no ' ;
54+ $ isLocked = $ node -> isLocked () ? 'yes ' : 'no ' ;
4055 } catch (\Exception $ e ) {
41- $ isCheckedOut = $ formatter ->formatException ($ e );
56+ $ isLocked = $ formatter ->formatException ($ e );
4257 }
43- } else {
44- $ isCheckedOut = 'N/A ' ;
45- }
4658
47- try {
48- $ isLocked = $ currentNode ->isLocked () ? 'yes ' : 'no ' ;
49- } catch (\Exception $ e ) {
50- $ isLocked = $ formatter ->formatException ($ e );
51- }
59+ $ info = array (
60+ 'UUID ' => $ node ->hasProperty ('jcr:uuid ' ) ? $ node ->getProperty ('jcr:uuid ' )->getValue () : 'N/A ' ,
61+ 'Index ' => $ node ->getIndex (),
62+ 'Primary node type ' => $ node ->getPrimaryNodeType ()->getName (),
63+ 'Mixin node types ' => implode (', ' , $ mixinNodeTypeNames ),
64+ 'Checked out? ' => $ isCheckedOut ,
65+ 'Locked? ' => $ isLocked ,
66+ );
5267
53- $ info = array (
54- 'Path ' => $ currentNode ->getPath (),
55- 'UUID ' => $ currentNode ->hasProperty ('jcr:uuid ' ) ? $ currentNode ->getProperty ('jcr:uuid ' )->getValue () : 'N/A ' ,
56- 'Index ' => $ currentNode ->getIndex (),
57- 'Primary node type ' => $ currentNode ->getPrimaryNodeType ()->getName (),
58- 'Mixin node types ' => implode (', ' , $ mixinNodeTypeNames ),
59- 'Checked out? ' => $ isCheckedOut ,
60- 'Locked? ' => $ isLocked ,
61- );
68+ $ output ->writeln ('<path> ' . $ node ->getPath () . '</path> ' );
69+ $ table = $ this ->get ('helper.table ' )->create ();
6270
63- $ table = $ this ->get ('helper.table ' )->create ();
71+ foreach ($ info as $ label => $ value ) {
72+ $ table ->addRow (array ($ label , $ value ));
73+ }
6474
65- foreach ($ info as $ label => $ value ) {
66- $ table ->addRow (array ($ label , $ value ));
75+ $ table ->render ($ output );
6776 }
68-
69- $ table ->render ($ output );
7077 }
7178}
0 commit comments