Skip to content

Node List accepts UUID #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ alpha-4

- [node] copy,move and clone - Target paths automatically append basename if target is a node.
- [query] Always show path next to resultset
- [node] `node:list` Enable listing nodes by UUID

### Bugs Fixes

Expand Down
10 changes: 9 additions & 1 deletion features/phpcr_node_list.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Feature: List properites and chidren of current node
Feature: List properites and chidren of current nodeA
In order to list the properties and children of the current node
As a user that is logged into the shell
I should be able to run a command which does that
Expand Down Expand Up @@ -60,3 +60,11 @@ Feature: List properites and chidren of current node
"""
| @* | nt:base | |
"""

Scenario: List node by UUID
Given I execute the "node:list 842e61c0-09ab-42a9-87c0-308ccc90e6f4" command
Then the command should not fail
And I should see the following:
"""
jcr:uuid
"""
18 changes: 15 additions & 3 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\PropertyType;
use PHPCR\Util\UUIDHelper;

class NodeListCommand extends Command
{
Expand All @@ -19,7 +20,7 @@ class NodeListCommand extends Command
protected function configure()
{
$this->setName('node:list');
$this->setDescription('List the children / properties of this node');
$this->setDescription('List the children / properties of this node at the given path or with the given UUID');
$this->addArgument('path', InputArgument::OPTIONAL, 'Path of node', '.');
$this->addOption('children', null, InputOption::VALUE_NONE, 'List only the children of this node');
$this->addOption('properties', null, InputOption::VALUE_NONE, 'List only the properties of this node');
Expand All @@ -33,6 +34,11 @@ protected function configure()

The <info>node:list</info> command can also shows template nodes and properties as defined a nodes node-type by
using the <info>--template</info> option. Template nodes and properties are prefixed with the "@" symbol.

The command accepts wither a path (relative or absolute) to the node or a UUID.

PHPCRSH> node:list 842e61c0-09ab-42a9-87c0-308ccc90e6f4
PHPCRSH> node:list /tests/foobar
HERE
);
}
Expand All @@ -50,8 +56,14 @@ public function execute(InputInterface $input, OutputInterface $output)

$session = $this->getHelper('phpcr')->getSession();

$path = $session->getAbsPath($input->getArgument('path'));
$currentNode = $session->getNode($path);
$path = $input->getArgument('path');

if (true === UUIDHelper::isUUID($path)) {
$currentNode = $session->getNodeByIdentifier($path);
} else {
$path = $session->getAbsPath($path);
$currentNode = $session->getNode($path);
}

if (!$this->showChildren && !$this->showProperties) {
$this->showChildren = true;
Expand Down