Skip to content

Commit 8b4a716

Browse files
committed
Merge pull request #148 from phpcr/show_full_path_for_top_level_node
always show the full path for the top level node in the dump
2 parents b568266 + 711eeeb commit 8b4a716

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/PHPCR/Util/Console/Helper/TreeDumper/ConsoleDumperNodeVisitor.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class ConsoleDumperNodeVisitor extends ConsoleDumperItemVisitor
2020
*/
2121
protected $identifiers;
2222

23+
/**
24+
* Show the full path for the node
25+
*/
26+
protected $showFullPath;
27+
2328
/**
2429
* Instantiate the console dumper visitor
2530
*
@@ -32,6 +37,16 @@ public function __construct(OutputInterface $output, $identifiers = false)
3237
$this->identifiers = $identifiers;
3338
}
3439

40+
/**
41+
* If to show the full path or not
42+
*
43+
* @param bool $showFullPath
44+
*/
45+
public function setShowFullPath($showFullPath)
46+
{
47+
$this->showFullPath = $showFullPath;
48+
}
49+
3550
/**
3651
* Print information about the visited node.
3752
*
@@ -43,10 +58,12 @@ public function visit(ItemInterface $item)
4358
throw new \Exception("Internal error: did not expect to visit a non-node object: $item");
4459
}
4560

46-
$name = $item->getName();
47-
4861
if ($item->getDepth() == 0) {
4962
$name = 'ROOT';
63+
} else if ($this->showFullPath) {
64+
$name = $item->getPath();
65+
} else {
66+
$name = $item->getName();
5067
}
5168

5269
$out = str_repeat(' ', $this->level)

src/PHPCR/Util/TreeWalker.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public function traverse(NodeInterface $node, $recurse = -1, $level = 0)
129129

130130
// Visit node
131131
$this->nodeVisitor->setLevel($level);
132+
$this->nodeVisitor->setShowFullPath(0 === $level);
132133
$node->accept($this->nodeVisitor);
133134

134135
// Visit properties

0 commit comments

Comments
 (0)