Skip to content

Commit 221482e

Browse files
committed
Merge pull request #45 from uwej711/fix_dump_command
Fix dump command
2 parents 006cca0 + 076c7d4 commit 221482e

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/PHPCR/Util/Console/Command/DumpCommand.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
namespace PHPCR\Util\Console\Command;
2323

24+
use PHPCR\Util\UUIDHelper;
2425
use Symfony\Component\Console\Command\Command;
2526
use PHPCR\ItemNotFoundException;
2627
use PHPCR\RepositoryException;
@@ -56,21 +57,22 @@ protected function configure()
5657
{
5758
$this
5859
->setName('phpcr:dump')
59-
->addOption('sys_nodes', null, InputOption::VALUE_OPTIONAL, 'Set to "yes" to dump the system nodes', "no")
60-
->addOption('props', null, InputOption::VALUE_OPTIONAL, 'Set to "yes" to dump the node properties', "no")
60+
->addOption('sys_nodes', null, InputOption::VALUE_NONE, 'Use to dump the system nodes')
61+
->addOption('props', null, InputOption::VALUE_NONE, 'Use to dump the node properties')
6162
->addOption('depth', null, InputOption::VALUE_OPTIONAL, 'Set to a number to limit how deep into the tree to recurse', "-1")
62-
->addOption('identifiers', null, InputOption::VALUE_OPTIONAL, 'Set to "yes" to also output node UUID', 'no')
63-
->addArgument('identifier', InputArgument::OPTIONAL, 'Path or UUID of the node to dump', '/')
63+
->addOption('identifiers', null, InputOption::VALUE_NONE, 'Use to also output node UUID')
64+
->addArgument('identifier', InputArgument::OPTIONAL, 'Path of the node to dump', '/')
6465
->setDescription('Dump the content repository')
6566
->setHelp(<<<EOF
6667
The <info>dump</info> command recursively outputs the name of the node specified
67-
by the <info>path</info> argument and its subnodes in a yaml-like style.
68+
by the <info>identifier</info> argument and its subnodes in a yaml-like style.
6869
69-
If the <info>props</info> option is set to yes the nodes properties are
70+
If the <info>props</info> option is used the nodes properties are
7071
displayed as yaml arrays.
7172
By default the command filters out system nodes and properties (i.e. nodes and
7273
properties with names starting with 'jcr:'), the <info>sys_nodes</info> option
7374
allows to turn this filter off.
75+
allows to turn this filter off.
7476
EOF
7577
)
7678
;
@@ -114,14 +116,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
114116
}
115117

116118
try {
117-
$node = $session->getNodeByIdentifier($identifier);
119+
if (UUIDHelper::isUUID($identifier)) {
120+
$node = $session->getNodeByIdentifier($identifier);
121+
} else {
122+
$node = $session->getNode($identifier);
123+
}
118124
$walker->traverse($node, $input->getOption('depth'));
119125
} catch (RepositoryException $e) {
120126
if ($e instanceof PathNotFoundException || $e instanceof ItemNotFoundException) {
121127
$output->writeln("<error>Path '$identifier' does not exist</error>");
122-
123-
return 1;
124128
}
129+
$output->writeln('<error>Error: '.$e->getMessage().'</error>');
130+
131+
return 1;
125132
}
126133

127134
return 0;

0 commit comments

Comments
 (0)