-
Notifications
You must be signed in to change notification settings - Fork 19
Support for deactivating commands if they are not supported #13
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,9 @@ | |
| use Symfony\Component\Console\Output\OutputInterface; | ||
| use Symfony\Component\Console\Input\InputArgument; | ||
| use Symfony\Component\Console\Input\InputOption; | ||
| use PHPCR\RepositoryInterface; | ||
|
|
||
| class LockInfoCommand extends Command | ||
| class LockInfoCommand extends PhpcrShellCommand | ||
| { | ||
| protected function configure() | ||
| { | ||
|
|
@@ -23,6 +24,9 @@ protected function configure() | |
| above that node. | ||
| HERE | ||
| ); | ||
|
|
||
| $this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true); | ||
| $this->dequiresDescriptor('jackalope.not_implemented.lock.get'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is dequires??? blew my mind!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. opposite of requires .. it requires that the given option is NOT set. |
||
| } | ||
|
|
||
| public function execute(InputInterface $input, OutputInterface $output) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,9 @@ | |
| use Symfony\Component\Console\Output\OutputInterface; | ||
| use Symfony\Component\Console\Input\InputArgument; | ||
| use Symfony\Component\Console\Input\InputOption; | ||
| use PHPCR\RepositoryInterface; | ||
|
|
||
| class LockTokenListCommand extends Command | ||
| class LockTokenListCommand extends PhpcrShellCommand | ||
| { | ||
| protected function configure() | ||
| { | ||
|
|
@@ -22,6 +23,8 @@ protected function configure() | |
| locks, since session-scoped locks do not have tokens. | ||
| HERE | ||
| ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inconsistency see? |
||
| $this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true); | ||
| $this->dequiresDescriptor('jackalope.not_implemented.lock.token'); | ||
| } | ||
|
|
||
| public function execute(InputInterface $input, OutputInterface $output) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,8 +10,9 @@ | |
| use PHPCR\NodeType\NoSuchNodeTypeException; | ||
| use PHPCR\Util\CND\Parser\CndParser; | ||
| use PHPCR\NamespaceException; | ||
| use PHPCR\RepositoryInterface; | ||
|
|
||
| class NodeLifecycleFollowCommand extends Command | ||
| class NodeLifecycleFollowCommand extends PhpcrShellCommand | ||
| { | ||
| protected function configure() | ||
| { | ||
|
|
@@ -30,6 +31,8 @@ protected function configure() | |
| need to call save. | ||
| HERE | ||
| ); | ||
|
|
||
| $this->requiresDescriptor(RepositoryInterface::OPTION_LIFECYCLE_SUPPORTED, true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so the interface has to do with the implementations? should not the same Repository implementations should have these options there?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are capacilties defined by PHPCR, so are part of the PHPCR interface. The implementations can add their own capbilties if they choose, but obviously they will not be standard. |
||
| } | ||
|
|
||
| public function execute(InputInterface $input, OutputInterface $output) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?php | ||
|
|
||
| namespace PHPCR\Shell\Console\Command; | ||
|
|
||
| use Symfony\Component\Console\Command\Command; | ||
|
|
||
| class PhpcrShellCommand extends Command | ||
| { | ||
| protected $descriptorRequires = array(); | ||
| protected $descriptorDequires = array(); | ||
|
|
||
| public function requiresDescriptor($descriptorKey, $value = null) | ||
| { | ||
| $this->descriptorRequires[$descriptorKey] = $value; | ||
| } | ||
|
|
||
| public function dequiresDescriptor($descriptorKey, $value = null) | ||
| { | ||
| $this->descriptorDequires[$descriptorKey] = $value; | ||
| } | ||
|
|
||
| public function isEnabled() | ||
| { | ||
| foreach ($this->descriptorRequires as $key => $value) { | ||
| $has = $this->getHelper('repository')->hasDescriptor($key, $value); | ||
| if (!$has) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| foreach ($this->descriptorDequires as $key => $value) { | ||
| $has = $this->getHelper('repository')->hasDescriptor($key, $value); | ||
|
|
||
| if ($has) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe that helper thing needs to take a set multiple don't you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be easiser ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/gushphp/gush/pull/99/files#r11073069