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
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ protected function configure()
4040
public function execute(InputInterface $input, OutputInterface $output)
4141
{
4242
$session = $this->getHelper('phpcr')->getSession();
43-
$path = $session->getAbsPath($input->getArgument('path'));
43+
$path = $input->getArgument('path');
4444
$srcChildRelPath = $input->getArgument('srcChildRelPath');
4545
$destChildRelPath = $input->getArgument('destChildRelPath');
46-
$node = $session->getNode($path);
46+
$node = $session->getNodeByPathOrIdentifier($path);
4747
$node->orderBefore($srcChildRelPath, $destChildRelPath);
4848
}
4949
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ protected function configure()
4040
public function execute(InputInterface $input, OutputInterface $output)
4141
{
4242
$session = $this->getHelper('phpcr')->getSession();
43-
$path = $session->getAbsPath($input->getArgument('path'));
44-
$currentNode = $session->getNode($path);
43+
$path = $input->getArgument('path');
44+
$currentNode = $session->getNodeByPathOrIdentifier($path);
4545
$name = $input->getArgument('name');
4646

4747
$references = array(

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ protected function configure()
2323
public function execute(InputInterface $input, OutputInterface $output)
2424
{
2525
$session = $this->getHelper('phpcr')->getSession();
26-
$targetPath = $session->getAbsPath($input->getArgument('path'));
26+
$targetPath = $input->getArgument('path');
2727
$currentPath = $session->getCwd();
2828

2929
// verify that node exists by trying to get it..
30-
$targetNode = $session->getNode($targetPath);
30+
$targetNode = $session->getNodeByPathOrIdentifier($targetPath);
3131

32-
if ($targetPath == '/') {
32+
if ($targetNode->getPath() == '/') {
3333
throw new \InvalidArgumentException(
3434
'You cannot delete the root node!'
3535
);
@@ -38,8 +38,7 @@ public function execute(InputInterface $input, OutputInterface $output)
3838
$session->removeItem($targetPath);
3939

4040
// if we deleted the current path, switch back to the parent node
41-
if ($currentPath == $targetPath) {
42-
echo $currentPath . ' vs. ' . $targetPath;
41+
if ($currentPath == $session->getAbsPath($targetPath)) {
4342
$session->chdir('..');
4443
}
4544
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ protected function configure()
5757
public function execute(InputInterface $input, OutputInterface $output)
5858
{
5959
$session = $this->getHelper('phpcr')->getSession();
60-
$path = $session->getAbsPath($input->getArgument('path'));
60+
$path = $input->getArgument('path');
6161
$newName = $input->getArgument('newName');
62-
$currentNode = $session->getNode($path);
62+
$currentNode = $session->getNodeByPathOrIdentifier($path);
6363
$currentNode->rename($newName);
6464
}
6565
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ protected function configure()
3131
public function execute(InputInterface $input, OutputInterface $output)
3232
{
3333
$session = $this->getHelper('phpcr')->getSession();
34-
$path = $session->getAbsPath($input->getArgument('path'));
34+
$path = $input->getArgument('path');
3535
$nodeTypeName = $input->getArgument('nodeTypeName');
3636

37-
$currentNode = $session->getNode($path);
37+
$currentNode = $session->getNodeByPathOrIdentifier($path);
3838
$currentNode->setPrimaryType($nodeTypeName);
3939
}
4040
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ protected function configure()
3232
public function execute(InputInterface $input, OutputInterface $output)
3333
{
3434
$session = $this->getHelper('phpcr')->getSession();
35-
$path = $session->getAbsPath($input->getArgument('path'));
36-
$currentNode = $session->getNode($path);
35+
$path = $input->getArgument('path');
36+
$currentNode = $session->getNodeByPathOrIdentifier($path);
3737
$sharedSet = $currentNode->removeSharedSet();
3838
}
3939
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ protected function configure()
3131
public function execute(InputInterface $input, OutputInterface $output)
3232
{
3333
$session = $this->getHelper('phpcr')->getSession();
34-
$path = $session->getAbsPath($input->getArgument('path'));
35-
$currentNode = $session->getNode($path);
34+
$path = $input->getArgument('path');
35+
$currentNode = $session->getNodeByPathOrIdentifier($path);
3636
$sharedSet = $currentNode->getSharedSet();
3737

3838
foreach ($sharedSet as $sharedNode) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public function execute(InputInterface $input, OutputInterface $output)
4242
$this->showChildren = $input->getOption('children');
4343
$this->showProperties = $input->getOption('properties');
4444

45-
$path = $session->getAbsPath($input->getArgument('path'));
46-
$currentNode = $session->getNode($path);
45+
$path = $input->getArgument('path');
46+
$currentNode = $session->getNodeByPathOrIdentifier($path);
4747

4848
if (!$showChildren && !$showProperties) {
4949
$this->showChildren = true;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ protected function configure()
3737
public function execute(InputInterface $input, OutputInterface $output)
3838
{
3939
$session = $this->getHelper('phpcr')->getSession();
40-
$path = $session->getAbsPath($input->getArgument('path'));
40+
$path = $input->getArgument('path');
4141
$srcWorkspace = $input->getArgument('srcWorkspace');
42-
$currentNode = $session->getNode($path);
42+
$currentNode = $session->getNodeByPathOrIdentifier($path);
4343
$currentNode->update($srcWorkspace);
4444
}
4545
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ public function execute(InputInterface $input, OutputInterface $output)
4949
{
5050
$session = $this->getHelper('phpcr')->getSession();
5151
$nodeHelper = $this->getHelper('node');
52-
$path = $session->getAbsPath($input->getArgument('path'));
52+
$path = $input->getArgument('path');
5353
$workspace = $session->getWorkspace();
5454

5555
$versionManager = $workspace->getVersionManager();
5656

57-
$node = $session->getNode($path);
57+
$node = $session->getNodeByPathOrIdentifier($path);
5858
$nodeHelper->assertNodeIsVersionable($node);
5959

6060
$version = $versionManager->checkin($path);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public function execute(InputInterface $input, OutputInterface $output)
3737
{
3838
$session = $this->getHelper('phpcr')->getSession();
3939
$nodeHelper = $this->getHelper('node');
40-
$absPath = $session->getAbsPath($input->getArgument('path'));
40+
$absPath = $input->getArgument('path');
4141
$workspace = $session->getWorkspace();
4242

43-
$node = $session->getNode($absPath);
43+
$node = $session->getNodeByPathOrIdentifier($absPath);
4444
$nodeHelper->assertNodeIsVersionable($node);
4545

4646
$versionManager = $workspace->getVersionManager();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ public function execute(InputInterface $input, OutputInterface $output)
2727
{
2828
$session = $this->getHelper('phpcr')->getSession();
2929
$nodeHelper = $this->getHelper('node');
30-
$path = $session->getAbsPath($input->getArgument('path'));
30+
$path = $input->getArgument('path');
3131
$workspace = $session->getWorkspace();
3232

33-
$node = $session->getNode($path);
33+
$node = $session->getNodeByPathOrIdentifier($path);
3434
$nodeHelper->assertNodeIsVersionable($node);
3535
$versionManager = $workspace->getVersionManager();
3636
$version = $versionManager->checkpoint($path);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public function execute(InputInterface $input, OutputInterface $output)
2626
$nodeHelper = $this->getHelper('node');
2727
$table = $this->getHelper('table')->create();
2828

29-
$path = $session->getAbsPath($input->getArgument('path'));
29+
$path = $input->getArgument('path');
3030
$workspace = $session->getWorkspace();
3131

32-
$node = $session->getNode($path);
32+
$node = $session->getNodeByPathOrIdentifier($path);
3333
$nodeHelper->assertNodeIsVersionable($node);
3434
$versionManager = $workspace->getVersionManager();
3535
$history = $versionManager->getVersionHistory($path);

0 commit comments

Comments
 (0)