|
21 | 21 |
|
22 | 22 | namespace PHPCR\Util\Console\Command; |
23 | 23 |
|
| 24 | +use PHPCR\Util\UUIDHelper; |
24 | 25 | use Symfony\Component\Console\Command\Command; |
25 | 26 | use PHPCR\ItemNotFoundException; |
26 | 27 | use PHPCR\RepositoryException; |
@@ -56,21 +57,22 @@ protected function configure() |
56 | 57 | { |
57 | 58 | $this |
58 | 59 | ->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') |
61 | 62 | ->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', '/') |
64 | 65 | ->setDescription('Dump the content repository') |
65 | 66 | ->setHelp(<<<EOF |
66 | 67 | 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. |
68 | 69 |
|
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 |
70 | 71 | displayed as yaml arrays. |
71 | 72 | By default the command filters out system nodes and properties (i.e. nodes and |
72 | 73 | properties with names starting with 'jcr:'), the <info>sys_nodes</info> option |
73 | 74 | allows to turn this filter off. |
| 75 | +allows to turn this filter off. |
74 | 76 | EOF |
75 | 77 | ) |
76 | 78 | ; |
@@ -114,14 +116,19 @@ protected function execute(InputInterface $input, OutputInterface $output) |
114 | 116 | } |
115 | 117 |
|
116 | 118 | try { |
117 | | - $node = $session->getNodeByIdentifier($identifier); |
| 119 | + if (UUIDHelper::isUUID($identifier)) { |
| 120 | + $node = $session->getNodeByIdentifier($identifier); |
| 121 | + } else { |
| 122 | + $node = $session->getNode($identifier); |
| 123 | + } |
118 | 124 | $walker->traverse($node, $input->getOption('depth')); |
119 | 125 | } catch (RepositoryException $e) { |
120 | 126 | if ($e instanceof PathNotFoundException || $e instanceof ItemNotFoundException) { |
121 | 127 | $output->writeln("<error>Path '$identifier' does not exist</error>"); |
122 | | - |
123 | | - return 1; |
124 | 128 | } |
| 129 | + $output->writeln('<error>Error: '.$e->getMessage().'</error>'); |
| 130 | + |
| 131 | + return 1; |
125 | 132 | } |
126 | 133 |
|
127 | 134 | return 0; |
|
0 commit comments