Skip to content

Commit 3d0bc36

Browse files
committed
Merge pull request #64 from phpcr/always_accept_uuid_for_path
Always accept UUID in addition to path
2 parents 72e3eaf + 2ba159b commit 3d0bc36

24 files changed

+156
-63
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ alpha-4
88

99
- [node] copy,move and clone - Target paths automatically append basename if target is a node.
1010
- [query] Always show path next to resultset
11-
- [node] `node:list` Enable listing nodes by UUID
11+
- [node|shell] Most commands which accept a node path can also accept a UUID
1212

1313
### Bugs Fixes
1414

features/shell_path_change.feature

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Feature: Change the shells current working path
2+
In order to change the current working path of the shell
3+
As a user that is logged into the shell
4+
I should be able to run a command which does that
5+
6+
Background:
7+
Given that I am logged in as "testuser"
8+
And the "session_data.xml" fixtures are loaded
9+
10+
Scenario: Change the current working path to root
11+
Given the current node is "/tests_general_base"
12+
And I execute the "shell:path:change /" command
13+
Then the command should not fail
14+
And the current node should be "/"
15+
16+
Scenario: Change the current working path
17+
Given the current node is "/"
18+
And I execute the "shell:path:change /tests_general_base" command
19+
Then the command should not fail
20+
And the current node should be "/tests_general_base"
21+
22+
Scenario: Change the current working path with a UUID
23+
Given the current node is "/"
24+
And I execute the "shell:path:change 842e61c0-09ab-42a9-87c0-308ccc90e6f4" command
25+
Then the command should not fail
26+
And the current node should be "/tests_general_base/idExample"

src/PHPCR/Shell/Console/Command/Phpcr/NodeCorrespondingCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ protected function configure()
2525
public function execute(InputInterface $input, OutputInterface $output)
2626
{
2727
$session = $this->getHelper('phpcr')->getSession();
28-
$path = $session->getAbsPath($input->getArgument('path'));
28+
$path = $input->getArgument('path');
2929
$workspaceName = $input->getArgument('workspaceName');
30-
$currentNode = $session->getNode($path);
30+
$currentNode = $session->getNodeByPathOrIdentifier($path);
3131
$correspondingPath = $currentNode->getCorrespondingNodePath($workspaceName);
3232
$output->writeln($correspondingPath);
3333
}

src/PHPCR/Shell/Console/Command/Phpcr/NodeDefinitionCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class NodeDefinitionCommand extends PhpcrShellCommand
1212
protected function configure()
1313
{
1414
$this->setName('node:definition');
15-
$this->setDescription('Show the CND Definition of current node');
15+
$this->setDescription('Show the CND Definition of specified node');
1616
$this->addArgument('path', InputArgument::REQUIRED, 'Path of node');
1717
$this->setHelp(<<<HERE
1818
Show the CND definition of the primary type of the current node.
@@ -25,8 +25,8 @@ protected function configure()
2525
public function execute(InputInterface $input, OutputInterface $output)
2626
{
2727
$session = $this->getHelper('phpcr')->getSession();
28-
$path = $session->getAbsPath($input->getArgument('path'));
29-
$currentNode = $session->getNode($path);
28+
$path = $input->getArgument('path');
29+
$currentNode = $session->getNodeByPathOrIdentifier($path);
3030
$workspace = $session->getWorkspace();
3131
$namespaceRegistry = $workspace->getNamespaceRegistry();
3232

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace PHPCR\Shell\Console\Command\Phpcr;
4+
5+
use Symfony\Component\Console\Command\Command;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
use Symfony\Component\Console\Input\InputArgument;
9+
10+
class NodeEditCommand extends Command
11+
{
12+
protected function configure()
13+
{
14+
$this->setName('node:edit');
15+
$this->setDescription('Edit the given node in the EDITOR configured by the system');
16+
$this->addArgument('path', InputArgument::REQUIRED, 'Path of node');
17+
$this->setHelp(<<<HERE
18+
Edit the given node
19+
HERE
20+
);
21+
}
22+
23+
public function execute(InputInterface $input, OutputInterface $output)
24+
{
25+
$session = $this->getHelper('phpcr')->getSession();
26+
$formatter = $this->getHelper('result_formatter');
27+
$path = $session->getAbsPath($input->getArgument('path'));
28+
29+
$editor = $this->getHelper('editor');
30+
31+
$skipBinary = true;
32+
$noRecurse = true;
33+
34+
ob_start();
35+
$stream = fopen('php://output', 'w+', false);
36+
$session->exportSystemView($path, $stream, $skipBinary, $noRecurse);
37+
$out = ob_get_clean();
38+
fclose($stream);
39+
$out = $formatter->formatXml($out);
40+
41+
$in = $editor->fromString($out);
42+
}
43+
}
44+

src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ protected function configure()
2323
public function execute(InputInterface $input, OutputInterface $output)
2424
{
2525
$session = $this->getHelper('phpcr')->getSession();
26-
$path = $session->getAbsPath($input->getArgument('path'));
26+
$path = $input->getArgument('path');
2727
$nodeHelper = $this->getHelper('node');
28-
$currentNode = $session->getNode($path);
28+
$currentNode = $session->getNodeByPathOrIdentifier($path);
2929
$formatter = $this->getHelper('result_formatter');
3030

3131
$mixins = $currentNode->getMixinNodeTypes();

src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleFollowCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ protected function configure()
3535
public function execute(InputInterface $input, OutputInterface $output)
3636
{
3737
$session = $this->getHelper('phpcr')->getSession();
38-
$path = $session->getAbsPath($input->getArgument('path'));
39-
$currentNode = $session->getNode($path);
38+
$path = $input->getArgument('path');
39+
$currentNode = $session->getNodeByPathOrIdentifier($path);
4040
$transition = $input->getArgument('transition');
4141
$currentNode->followLifecycleTransition($transition);
4242
}

src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleListCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ protected function configure()
2626
public function execute(InputInterface $input, OutputInterface $output)
2727
{
2828
$session = $this->getHelper('phpcr')->getSession();
29-
$path = $session->getAbsPath($input->getArgument('path'));
30-
$currentNode = $session->getNode($path);
29+
$path = $input->getArgument('path');
30+
$currentNode = $session->getNodeByPathOrIdentifier($path);
3131
$transitions = $currentNode->getAllowedLifecycleTransitions();
3232

3333
foreach ($transitions as $transition) {

src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Symfony\Component\Console\Input\InputArgument;
99
use Symfony\Component\Console\Input\InputOption;
1010
use PHPCR\PropertyType;
11-
use PHPCR\Util\UUIDHelper;
1211

1312
class NodeListCommand extends Command
1413
{
@@ -55,15 +54,9 @@ public function execute(InputInterface $input, OutputInterface $output)
5554
$this->showTemplate = $input->getOption('template');
5655

5756
$session = $this->getHelper('phpcr')->getSession();
58-
5957
$path = $input->getArgument('path');
6058

61-
if (true === UUIDHelper::isUUID($path)) {
62-
$currentNode = $session->getNodeByIdentifier($path);
63-
} else {
64-
$path = $session->getAbsPath($path);
65-
$currentNode = $session->getNode($path);
66-
}
59+
$currentNode = $session->getNodeByPathOrIdentifier($path);
6760

6861
if (!$this->showChildren && !$this->showProperties) {
6962
$this->showChildren = true;

src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinAddCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ protected function configure()
4444
public function execute(InputInterface $input, OutputInterface $output)
4545
{
4646
$session = $this->getHelper('phpcr')->getSession();
47-
$path = $session->getAbsPath($input->getArgument('path'));
47+
$path = $input->getArgument('path');
4848
$mixinName = $input->getArgument('mixinName');
49-
$currentNode = $session->getNode($path);
49+
$currentNode = $session->getNodeByPathOrIdentifier($path);
5050
$currentNode->addMixin($mixinName);
5151
}
5252
}

0 commit comments

Comments
 (0)