Skip to content

Commit 261c4de

Browse files
committed
Support for deactivating commands if they are not supported
1 parent 1a37dd1 commit 261c4de

21 files changed

+214
-34
lines changed

features/repository_descriptor_list.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ Feature: List Repository Descriptors
88
And I execute the "repository:descriptor:list" command
99
Then the command should not fail
1010
And I should see a table containing the following rows:
11-
| Key | Value |
12-
| jcr.repository.name | Jackrabbit |
13-
| jcr.repository.vendor | Apache Software Foundation |
11+
| Key | Value | Standard? |
12+
| jcr.repository.name | Jackrabbit | yes |
13+
| jcr.repository.vendor | Apache Software Foundation | yes |

src/PHPCR/Shell/Console/Application/ShellApplication.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@
9595
use Jackalope\NotImplementedException;
9696
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
9797
use Symfony\Component\Console\Formatter\OutputFormatter;
98+
use PHPCR\Shell\Console\Helper\RepositoryHelper;
99+
use PHPCR\Shell\Console\Command\PhpcrShellCommand;
98100

99101
class ShellApplication extends Application
100102
{
@@ -136,6 +138,16 @@ public function init()
136138
$this->transports[$transport->getName()] = $transport;;
137139
}
138140

141+
$session = $this->getSession($this->sessionInput);
142+
143+
$this->getHelperSet()->set(new EditorHelper($session));
144+
$this->getHelperSet()->set(new PhpcrConsoleDumperHelper());
145+
$this->getHelperSet()->set(new PhpcrHelper($session));
146+
$this->getHelperSet()->set(new ResultFormatterHelper());
147+
$this->getHelperSet()->set(new TextHelper());
148+
$this->getHelperSet()->set(new NodeHelper($session));
149+
$this->getHelperSet()->set(new RepositoryHelper($session->getRepository()));
150+
139151
// add new commands
140152
$this->add(new AccessControlPrivilegeListCommand());
141153
$this->add(new RepositoryDescriptorListCommand());
@@ -239,15 +251,6 @@ public function init()
239251
->setName('workspace-purge')
240252
);
241253

242-
$this->initSession();
243-
244-
$this->getHelperSet()->set(new EditorHelper($this->session));
245-
$this->getHelperSet()->set(new PhpcrConsoleDumperHelper());
246-
$this->getHelperSet()->set(new PhpcrHelper($this->session));
247-
$this->getHelperSet()->set(new ResultFormatterHelper());
248-
$this->getHelperSet()->set(new TextHelper());
249-
$this->getHelperSet()->set(new NodeHelper($this->session));
250-
251254
$this->initialized = true;
252255
}
253256

src/PHPCR/Shell/Console/Command/LockInfoCommand.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
use Symfony\Component\Console\Output\OutputInterface;
88
use Symfony\Component\Console\Input\InputArgument;
99
use Symfony\Component\Console\Input\InputOption;
10+
use PHPCR\RepositoryInterface;
1011

11-
class LockInfoCommand extends Command
12+
class LockInfoCommand extends PhpcrShellCommand
1213
{
1314
protected function configure()
1415
{
@@ -22,7 +23,10 @@ protected function configure()
2223
This may be either of the lock on that node itself or a deep lock on a node
2324
above that node.
2425
HERE
25-
);
26+
);
27+
28+
$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
29+
$this->dequiresDescriptor('jackalope.not_implemented.lock.get');
2630
}
2731

2832
public function execute(InputInterface $input, OutputInterface $output)

src/PHPCR/Shell/Console/Command/LockLockCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
use Symfony\Component\Console\Output\OutputInterface;
88
use Symfony\Component\Console\Input\InputArgument;
99
use Symfony\Component\Console\Input\InputOption;
10+
use PHPCR\RepositoryInterface;
1011

11-
class LockLockCommand extends Command
12+
class LockLockCommand extends PhpcrShellCommand
1213
{
1314
protected function configure()
1415
{
@@ -50,7 +51,8 @@ protected function configure()
5051
5152
It is possible to lock a node even if it is checked-in.
5253
HERE
53-
);
54+
);
55+
$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
5456
}
5557

5658
public function execute(InputInterface $input, OutputInterface $output)

src/PHPCR/Shell/Console/Command/LockRefreshCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
use Symfony\Component\Console\Output\OutputInterface;
88
use Symfony\Component\Console\Input\InputArgument;
99
use Symfony\Component\Console\Input\InputOption;
10+
use PHPCR\RepositoryInterface;
1011

11-
class LockRefreshCommand extends Command
12+
class LockRefreshCommand extends PhpcrShellCommand
1213
{
1314
protected function configure()
1415
{
@@ -23,6 +24,8 @@ protected function configure()
2324
has no effect.
2425
HERE
2526
);
27+
$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
28+
$this->dequiresDescriptor('jackalope.not_implemented.lock.refresh');
2629
}
2730

2831
public function execute(InputInterface $input, OutputInterface $output)

src/PHPCR/Shell/Console/Command/LockTokenAddCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
use Symfony\Component\Console\Output\OutputInterface;
88
use Symfony\Component\Console\Input\InputArgument;
99
use Symfony\Component\Console\Input\InputOption;
10+
use PHPCR\RepositoryInterface;
1011

11-
class LockTokenAddCommand extends Command
12+
class LockTokenAddCommand extends PhpcrShellCommand
1213
{
1314
protected function configure()
1415
{
@@ -22,6 +23,8 @@ protected function configure()
2223
specified by that particular lock token.
2324
HERE
2425
);
26+
$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
27+
$this->dequiresDescriptor('jackalope.not_implemented.lock.token');
2528
}
2629

2730
public function execute(InputInterface $input, OutputInterface $output)

src/PHPCR/Shell/Console/Command/LockTokenListCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
use Symfony\Component\Console\Output\OutputInterface;
88
use Symfony\Component\Console\Input\InputArgument;
99
use Symfony\Component\Console\Input\InputOption;
10+
use PHPCR\RepositoryInterface;
1011

11-
class LockTokenListCommand extends Command
12+
class LockTokenListCommand extends PhpcrShellCommand
1213
{
1314
protected function configure()
1415
{
@@ -22,6 +23,8 @@ protected function configure()
2223
locks, since session-scoped locks do not have tokens.
2324
HERE
2425
);
26+
$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
27+
$this->dequiresDescriptor('jackalope.not_implemented.lock.token');
2528
}
2629

2730
public function execute(InputInterface $input, OutputInterface $output)

src/PHPCR/Shell/Console/Command/LockTokenRemoveCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
use Symfony\Component\Console\Output\OutputInterface;
88
use Symfony\Component\Console\Input\InputArgument;
99
use Symfony\Component\Console\Input\InputOption;
10+
use PHPCR\RepositoryInterface;
1011

11-
class LockTokenRemoveCommand extends Command
12+
class LockTokenRemoveCommand extends PhpcrShellCommand
1213
{
1314
protected function configure()
1415
{
@@ -19,6 +20,8 @@ protected function configure()
1920
Removes the specified lock token from the current Session.
2021
HERE
2122
);
23+
$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
24+
$this->dequiresDescriptor('jackalope.not_implemented.lock.token');
2225
}
2326

2427
public function execute(InputInterface $input, OutputInterface $output)

src/PHPCR/Shell/Console/Command/LockUnlockCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
use Symfony\Component\Console\Output\OutputInterface;
88
use Symfony\Component\Console\Input\InputArgument;
99
use Symfony\Component\Console\Input\InputOption;
10+
use PHPCR\RepositoryInterface;
1011

11-
class LockUnlockCommand extends Command
12+
class LockUnlockCommand extends PhpcrShellCommand
1213
{
1314
protected function configure()
1415
{
@@ -35,6 +36,7 @@ protected function configure()
3536
lock-related properties will be changed despite the checked-in status).
3637
HERE
3738
);
39+
$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
3840
}
3941

4042
public function execute(InputInterface $input, OutputInterface $output)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
use PHPCR\NodeType\NoSuchNodeTypeException;
1111
use PHPCR\Util\CND\Parser\CndParser;
1212
use PHPCR\NamespaceException;
13+
use PHPCR\RepositoryInterface;
1314

14-
class NodeLifecycleFollowCommand extends Command
15+
class NodeLifecycleFollowCommand extends PhpcrShellCommand
1516
{
1617
protected function configure()
1718
{
@@ -30,6 +31,8 @@ protected function configure()
3031
need to call save.
3132
HERE
3233
);
34+
35+
$this->requiresDescriptor(RepositoryInterface::OPTION_LIFECYCLE_SUPPORTED, true);
3336
}
3437

3538
public function execute(InputInterface $input, OutputInterface $output)

0 commit comments

Comments
 (0)