├── .github └── workflows │ └── test-application.yaml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── behat.yml ├── bin └── phpcrsh ├── box.json ├── composer.json ├── features ├── all │ ├── phpcr_access_control_privilege_list.feature │ ├── phpcr_file_import.feature │ ├── phpcr_lock_info.feature │ ├── phpcr_lock_lock.feature │ ├── phpcr_lock_refresh.feature │ ├── phpcr_lock_token_add.feature │ ├── phpcr_lock_token_list.feature │ ├── phpcr_lock_token_remove.feature │ ├── phpcr_lock_unlock.feature │ ├── phpcr_namespace_unregister.feature │ ├── phpcr_node_clone.feature │ ├── phpcr_node_copy.feature │ ├── phpcr_node_corresponding.feature │ ├── phpcr_node_create.feature │ ├── phpcr_node_edit.feature │ ├── phpcr_node_info.feature │ ├── phpcr_node_lifecycle_follow_transition.feature │ ├── phpcr_node_lifecycle_list.feature │ ├── phpcr_node_list.feature │ ├── phpcr_node_mixin_add.feature │ ├── phpcr_node_mixin_remove.feature │ ├── phpcr_node_move.feature │ ├── phpcr_node_property_remove.feature │ ├── phpcr_node_property_set.feature │ ├── phpcr_node_property_show.feature │ ├── phpcr_node_references.feature │ ├── phpcr_node_remove.feature │ ├── phpcr_node_rename.feature │ ├── phpcr_node_reorder_before.feature │ ├── phpcr_node_set_primary_type.feature │ ├── phpcr_node_shared_show.feature │ ├── phpcr_node_type_edit.feature │ ├── phpcr_node_type_list.feature │ ├── phpcr_node_type_load.feature │ ├── phpcr_node_type_show.feature │ ├── phpcr_node_type_unregister.feature │ ├── phpcr_node_update.feature │ ├── phpcr_query.feature │ ├── phpcr_query_delete.feature │ ├── phpcr_query_select.feature │ ├── phpcr_query_update.feature │ ├── phpcr_repository_descriptor_list.feature │ ├── phpcr_retention_hold_add.feature │ ├── phpcr_retention_hold_list.feature │ ├── phpcr_retention_hold_remove.feature │ ├── phpcr_retention_policy_get.feature │ ├── phpcr_retention_policy_remove.feature │ ├── phpcr_session_export.feature │ ├── phpcr_session_impersonate.feature │ ├── phpcr_session_import.feature │ ├── phpcr_session_info.feature │ ├── phpcr_session_namespace_list.feature │ ├── phpcr_session_namespace_set.feature │ ├── phpcr_session_refresh.feature │ ├── phpcr_session_save.feature │ ├── phpcr_version_checkin.feature │ ├── phpcr_version_checkout.feature │ ├── phpcr_version_checkpoint.feature │ ├── phpcr_version_history.feature │ ├── phpcr_version_remove.feature │ └── phpcr_version_restore.feature ├── cli │ └── doctrine-dbal.feature ├── fixtures │ ├── all_property_types.xml │ ├── cms.xml │ ├── example.cnd │ ├── files │ │ └── phpcrlogos.png │ ├── jackalope-doctrine-dbal-cli-config.php │ ├── session_data.xml │ └── versionable.xml ├── shell │ ├── shell_alias.feature │ ├── shell_autocomplete.feature │ ├── shell_clear.feature │ ├── shell_config_init.feature │ ├── shell_config_reload.feature │ ├── shell_exit.feature │ ├── shell_path_change.feature │ └── shell_profile_show.feature └── standalone │ ├── phpcr_session_login.feature │ ├── phpcr_session_logout.feature │ ├── phpcr_workspace_create.feature │ ├── phpcr_workspace_delete.feature │ ├── phpcr_workspace_list.feature │ ├── phpcr_workspace_namespace_list.feature │ ├── phpcr_workspace_namespace_register.feature │ ├── phpcr_workspace_namespace_unregister.feature │ └── phpcr_workspace_use.feature ├── phpunit.xml.dist ├── spec └── PHPCR │ └── Shell │ ├── Config │ ├── ConfigManagerSpec.php │ ├── ConfigSpec.php │ ├── ProfileLoaderSpec.php │ ├── ProfileSpec.php │ ├── fixtures │ │ └── config │ │ │ └── alias.yml │ └── profiles │ │ ├── one.yml │ │ └── two.yml │ ├── Console │ ├── Application │ │ ├── EmbeddedApplicationSpec.php │ │ └── ShellApplicationSpec.php │ ├── Helper │ │ ├── EditorHelperSpec.php │ │ ├── NodeHelperSpec.php │ │ ├── PathHelperSpec.php │ │ ├── RepositoryHelperSpec.php │ │ ├── ResultFormatterHelperSpec.php │ │ └── TextHelperSpec.php │ └── Input │ │ └── StringInputSpec.php │ ├── Event │ ├── ApplicationInitEventSpec.php │ ├── CommandExceptionEventSpec.php │ └── ProfileInitEventSpec.php │ ├── Phpcr │ └── SessionManagerSpec.php │ ├── Query │ └── UpdateParserSpec.php │ ├── Serializer │ ├── NodeNormalizerSpec.php │ └── YamlEncoderSpec.php │ ├── Subscriber │ └── AliasSubscriberSpec.php │ └── Transport │ ├── Transport │ ├── DoctrineDbalSpec.php │ └── JackrabbitSpec.php │ └── TransportRegistrySpec.php ├── src └── PHPCR │ └── Shell │ ├── Config │ ├── Config.php │ ├── ConfigManager.php │ ├── Exception │ │ └── FileExistsException.php │ ├── Profile.php │ └── ProfileLoader.php │ ├── Console │ ├── Application │ │ ├── EmbeddedApplication.php │ │ ├── SessionApplication.php │ │ ├── Shell.php │ │ └── ShellApplication.php │ ├── Command │ │ ├── BaseCommand.php │ │ ├── Phpcr │ │ │ ├── AccessControlPrivilegeListCommand.php │ │ │ ├── BasePhpcrCommand.php │ │ │ ├── BaseQueryCommand.php │ │ │ ├── LockInfoCommand.php │ │ │ ├── LockLockCommand.php │ │ │ ├── LockRefreshCommand.php │ │ │ ├── LockTokenAddCommand.php │ │ │ ├── LockTokenListCommand.php │ │ │ ├── LockTokenRemoveCommand.php │ │ │ ├── LockUnlockCommand.php │ │ │ ├── NodeCloneCommand.php │ │ │ ├── NodeCopyCommand.php │ │ │ ├── NodeCorrespondingCommand.php │ │ │ ├── NodeCreateCommand.php │ │ │ ├── NodeEditCommand.php │ │ │ ├── NodeFileImportCommand.php │ │ │ ├── NodeInfoCommand.php │ │ │ ├── NodeLifecycleFollowCommand.php │ │ │ ├── NodeLifecycleListCommand.php │ │ │ ├── NodeListCommand.php │ │ │ ├── NodeMixinAddCommand.php │ │ │ ├── NodeMixinRemoveCommand.php │ │ │ ├── NodeMoveCommand.php │ │ │ ├── NodeOrderBeforeCommand.php │ │ │ ├── NodePropertyRemoveCommand.php │ │ │ ├── NodePropertySetCommand.php │ │ │ ├── NodePropertyShowCommand.php │ │ │ ├── NodeReferencesCommand.php │ │ │ ├── NodeRemoveCommand.php │ │ │ ├── NodeRenameCommand.php │ │ │ ├── NodeSetPrimaryTypeCommand.php │ │ │ ├── NodeSharedShowCommand.php │ │ │ ├── NodeTypeEditCommand.php │ │ │ ├── NodeTypeListCommand.php │ │ │ ├── NodeTypeLoadCommand.php │ │ │ ├── NodeTypeShowCommand.php │ │ │ ├── NodeTypeUnregisterCommand.php │ │ │ ├── NodeUpdateCommand.php │ │ │ ├── QueryCommand.php │ │ │ ├── QueryDeleteCommand.php │ │ │ ├── QuerySelectCommand.php │ │ │ ├── QueryUpdateCommand.php │ │ │ ├── RepositoryDescriptorListCommand.php │ │ │ ├── RetentionHoldAddCommand.php │ │ │ ├── RetentionHoldListCommand.php │ │ │ ├── RetentionHoldRemoveCommand.php │ │ │ ├── RetentionPolicyGetCommand.php │ │ │ ├── RetentionPolicyRemoveCommand.php │ │ │ ├── SessionExportCommand.php │ │ │ ├── SessionImpersonateCommand.php │ │ │ ├── SessionImportCommand.php │ │ │ ├── SessionInfoCommand.php │ │ │ ├── SessionLoginCommand.php │ │ │ ├── SessionLogoutCommand.php │ │ │ ├── SessionNamespaceListCommand.php │ │ │ ├── SessionNamespaceSetCommand.php │ │ │ ├── SessionRefreshCommand.php │ │ │ ├── SessionSaveCommand.php │ │ │ ├── VersionCheckinCommand.php │ │ │ ├── VersionCheckoutCommand.php │ │ │ ├── VersionCheckpointCommand.php │ │ │ ├── VersionHistoryCommand.php │ │ │ ├── VersionRemoveCommand.php │ │ │ ├── VersionRestoreCommand.php │ │ │ ├── WorkspaceCreateCommand.php │ │ │ ├── WorkspaceDeleteCommand.php │ │ │ ├── WorkspaceListCommand.php │ │ │ ├── WorkspaceNamespaceListCommand.php │ │ │ ├── WorkspaceNamespaceRegisterCommand.php │ │ │ ├── WorkspaceNamespaceUnregisterCommand.php │ │ │ └── WorkspaceUseCommand.php │ │ ├── Shell │ │ │ ├── AliasListCommand.php │ │ │ ├── ClearCommand.php │ │ │ ├── ConfigInitCommand.php │ │ │ ├── ConfigReloadCommand.php │ │ │ ├── ExitCommand.php │ │ │ ├── PathChangeCommand.php │ │ │ ├── PathShowCommand.php │ │ │ └── ProfileShowCommand.php │ │ └── ShellCommand.php │ ├── Helper │ │ ├── EditorHelper.php │ │ ├── NodeHelper.php │ │ ├── PathHelper.php │ │ ├── RepositoryHelper.php │ │ ├── ResultFormatterHelper.php │ │ ├── Table.php │ │ └── TextHelper.php │ └── Input │ │ ├── AutoComplete.php │ │ └── StringInput.php │ ├── DependencyInjection │ ├── Container.php │ └── ContainerAwareInterface.php │ ├── Event │ ├── ApplicationInitEvent.php │ ├── CommandExceptionEvent.php │ ├── CommandPreRunEvent.php │ ├── Event.php │ ├── PhpcrShellEvents.php │ └── ProfileInitEvent.php │ ├── Phpcr │ ├── PhpcrSession.php │ └── SessionManager.php │ ├── PhpcrShell.php │ ├── Query │ ├── ColumnOperand.php │ ├── FunctionOperand.php │ ├── UpdateParser.php │ ├── UpdateProcessor.php │ └── Validator.php │ ├── Resources │ └── config.dist │ │ ├── alias.yml │ │ └── phpcrsh.yml │ ├── Serializer │ ├── NodeNormalizer.php │ └── YamlEncoder.php │ ├── Subscriber │ ├── AliasSubscriber.php │ ├── AutoSaveSubscriber.php │ ├── ConfigInitSubscriber.php │ ├── ExceptionSubscriber.php │ ├── ProfileFromSessionInputSubscriber.php │ ├── ProfileLoaderSubscriber.php │ └── ProfileWriterSubscriber.php │ ├── Test │ ├── ApplicationTester.php │ ├── CliContext.php │ ├── ContextBase.php │ ├── EmbeddedContext.php │ └── StandaloneContext.php │ └── Transport │ ├── Transport │ ├── DoctrineDbal.php │ ├── JackalopeFs.php │ └── Jackrabbit.php │ ├── TransportInterface.php │ ├── TransportRegistry.php │ └── TransportRegistryInterface.php └── tests ├── PHPCR └── Shell │ ├── Helper │ ├── EditorHelperTest.php │ ├── NodeHelperTest.php │ └── TextHelperTest.php │ └── Phpcr │ └── PhpcrSessionTest.php └── bin └── travis_jackrabbit.sh /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | composer.lock 3 | phpcr.phar 4 | .phpunit.result.cache 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Daniel Leech 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Shell for PHPCR 2 | --------------- 3 | 4 | [![Test application](https://github.com/phpcr/phpcr-shell/workflows/Test%20application/badge.svg)](https://github.com/phpcr/phpcr-shell/actions?query=workflow%3A%22Test+application%22) 5 | 6 | ## Building 7 | 8 | The recommended way to use the PHPCR shell is as a phar archive. 9 | 10 | Install box: https://box-project.github.io/box2/ 11 | 12 | Build the PHAR: 13 | 14 | ````bash 15 | $ cd phpcr-shell 16 | $ box build 17 | ```` 18 | 19 | This will produce the file `phpcr.phar`. 20 | 21 | Copy this file to your bin directory: 22 | 23 | ````bash 24 | $ sudo cp phpcrsh.phar /usr/bin/local/phpcrsh 25 | ```` 26 | 27 | ## Documentation 28 | 29 | Read the documentation on [readthedocs](http://phpcr.readthedocs.org/en/latest/phpcr-shell/index.html) 30 | -------------------------------------------------------------------------------- /behat.yml: -------------------------------------------------------------------------------- 1 | default: 2 | suites: 3 | standalone: 4 | contexts: 5 | - PHPCR\Shell\Test\StandaloneContext 6 | paths: 7 | - features/all 8 | - features/standalone 9 | - features/shell 10 | embedded: 11 | filter: 12 | tag: "~@standalone" 13 | contexts: 14 | - PHPCR\Shell\Test\EmbeddedContext 15 | paths: 16 | - features/all 17 | cli: 18 | contexts: 19 | - PHPCR\Shell\Test\CliContext 20 | paths: 21 | - features/cli 22 | -------------------------------------------------------------------------------- /bin/phpcrsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | run(); 18 | -------------------------------------------------------------------------------- /box.json: -------------------------------------------------------------------------------- 1 | { 2 | "alias": "phpcrsh.phar", 3 | "chmod": "0755", 4 | "directories": ["src"], 5 | "files": [ 6 | "LICENSE" 7 | ], 8 | "exclude-dev-files": false, 9 | "finder": [ 10 | { 11 | "name": "*.php", 12 | "exclude": [ 13 | "tests", 14 | "behat", 15 | "Tests", 16 | "phpspec", 17 | "mockery", 18 | "phpunit" 19 | ], 20 | "in": "vendor" 21 | } 22 | ], 23 | "git-version": "package_version", 24 | "main": "bin/phpcrsh", 25 | "output": "phpcrsh.phar", 26 | "stub": true 27 | } 28 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "phpcr/phpcr-shell", 3 | "description": "Shell for PHPCR", 4 | "require": { 5 | "php": "^8.0", 6 | "jackalope/jackalope": "^1.3.4 || ^2.0", 7 | "symfony/console": "^5.4 || ^6.4 || ^7.0", 8 | "phpcr/phpcr": "^2.1", 9 | "phpcr/phpcr-utils": "^1.2 || ^2.0", 10 | "symfony/finder": "^5.4 || ^6.4 || ^7.0", 11 | "symfony/serializer": "^5.4 || ^6.4 || ^7.0", 12 | "symfony/yaml": "^5.4 || ^6.4 || ^7.0", 13 | "symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0", 14 | "symfony/expression-language": "^5.4 || ^6.4 || ^7.0", 15 | "dantleech/glob-finder": "^1.0" 16 | }, 17 | "require-dev": { 18 | "phpunit/phpunit": "^9.5", 19 | "behat/behat": "^3.10", 20 | "phpspec/phpspec": "^7.2", 21 | "jackalope/jackalope-doctrine-dbal": "^1.3 || ^2.0", 22 | "jackalope/jackalope-jackrabbit": "^1.4.4 || ^2.0", 23 | "phpspec/prophecy-phpunit": "^2.0" 24 | }, 25 | "suggest": { 26 | "jackalope/jackalope-doctrine-dbal": "To connect to jackalope doctrine-dbal", 27 | "jackalope/jackalope-jackrabbit": "To connect to jackalope jackrabbit", 28 | "jackalope/jackalope-jackrabbit-fs": "To connect to jackalope jackalope-fs" 29 | }, 30 | "license": "MIT", 31 | "authors": [ 32 | { 33 | "name": "dantleech", 34 | "email": "daniel@dantleech.com" 35 | } 36 | ], 37 | "conflict": { 38 | "doctrine/phpcr-bundle": "<=1.2.1" 39 | }, 40 | "autoload": { 41 | "psr-0": {"": "src"} 42 | }, 43 | "bin": ["bin/phpcrsh"] 44 | } 45 | -------------------------------------------------------------------------------- /features/all/phpcr_access_control_privilege_list.feature: -------------------------------------------------------------------------------- 1 | Feature: List the ac privileges for a given node 2 | In order to show the privleges for a given node 3 | As a logged in user 4 | I want to be able to execute a command which does that 5 | 6 | Scenario: Listing privileges 7 | Given that I am logged in as "testuser" 8 | And I execute the "access-control:privilege:list /tests_general_base" command 9 | Then I should see the following: 10 | """ 11 | Unsupported repository operation 12 | """ 13 | #Then the command should not fail 14 | #And I should see a table containing the following rows: 15 | # | Name | Abstract? | Aggregate ? | 16 | # | foo | yes | no | 17 | 18 | # Scenario: Listing all supported privileges 19 | # Given I execute the "access-control:privilege:list /tests_general_base --supported --verbose" command 20 | # Then the command should not fail 21 | # And I should see a table containing the following rows: 22 | # | Name | Abstract? | Aggregate ? | 23 | # | foo | yes | no | 24 | # 25 | # Scenario: List non node privileges 26 | # Given that I am logged in as "testuser" 27 | # And I execute the "access-control:privilege:list" command 28 | # Then the command should not fail 29 | # And I should see a table containing the following rows: 30 | # | Name | Abstract? | Aggregate ? | 31 | # | foo | yes | no | 32 | -------------------------------------------------------------------------------- /features/all/phpcr_lock_info.feature: -------------------------------------------------------------------------------- 1 | Feature: Show the details of a lock 2 | In order to show the details of a lock 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 | And the node at "/tests_general_base" has the mixin "mix:lockable" 10 | And the node "/tests_general_base" is locked 11 | 12 | Scenario: Create a new node 13 | Given I execute the "lock:info /tests_general_base" command 14 | Then the command should fail 15 | And I should see the following: 16 | """ 17 | Not implemented 18 | """ 19 | # And I should see the following: 20 | # """ 21 | # Lock Owner: admin 22 | # Lock Token: foobar 23 | # Seconds Remaining: 123 24 | # Deep?: yes 25 | # Live?: yes 26 | # Owned by current session?: no 27 | # Session Scoped?: no 28 | # """ 29 | 30 | -------------------------------------------------------------------------------- /features/all/phpcr_lock_lock.feature: -------------------------------------------------------------------------------- 1 | Feature: Lock the node at a given path 2 | In order to lock a node at a given path 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 | And the node at "/tests_general_base" has the mixin "mix:lockable" 10 | 11 | Scenario: Create a new lock 12 | Given I execute the "lock:lock /tests_general_base --deep --session-scoped --timeout=30 --owner-info=random" command 13 | Then the command should not fail 14 | And the node "/tests_general_base" should be locked 15 | -------------------------------------------------------------------------------- /features/all/phpcr_lock_refresh.feature: -------------------------------------------------------------------------------- 1 | Feature: Refresh the TTL of a lock 2 | In order to reset the TTL on the lock of a given node path 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 I execute the "lock:lock /tests_general_base --session-scoped --timeout=10" command 9 | 10 | Scenario: Create a new node 11 | And I execute the "lock:refresh /tests_general_base" command 12 | Then the command should fail 13 | And I should see the following: 14 | """ 15 | Not implemented 16 | """ 17 | -------------------------------------------------------------------------------- /features/all/phpcr_lock_token_add.feature: -------------------------------------------------------------------------------- 1 | Feature: Add a lock token in the current session 2 | In order to create a new lock token 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 | 9 | Scenario: Create a new node 10 | Given I execute the "lock:token:add foobar" command 11 | Then the command should fail 12 | Then I should see the following: 13 | """ 14 | Not implemented 15 | """ 16 | 17 | -------------------------------------------------------------------------------- /features/all/phpcr_lock_token_list.feature: -------------------------------------------------------------------------------- 1 | Feature: List the lock tokens registered with the current session 2 | In order to list the lock tokens registered in the current session 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 | 9 | Scenario: List lock tokens 10 | Given I execute the "lock:token:add foobar" command 11 | Then the command should fail 12 | """ 13 | Not implemented 14 | """ 15 | -------------------------------------------------------------------------------- /features/all/phpcr_lock_token_remove.feature: -------------------------------------------------------------------------------- 1 | Feature: Remove a lock token in the current session 2 | In order to create a new lock token 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 | 9 | Scenario: Create a new node 10 | Given I execute the "lock:token:remove foobar" command 11 | Then the command should fail 12 | Then I should see the following: 13 | """ 14 | Not implemented 15 | """ 16 | -------------------------------------------------------------------------------- /features/all/phpcr_lock_unlock.feature: -------------------------------------------------------------------------------- 1 | Feature: Unlock the node at a given path 2 | In order to unlock a node at a given path 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 | And the node at "/tests_general_base" has the mixin "mix:lockable" 10 | 11 | Scenario: Create a new node 12 | Given I execute the "lock:lock /tests_general_base --session-scoped" command 13 | And I execute the "lock:unlock /tests_general_base" command 14 | Then the command should not fail 15 | And the node "/tests_general_base" should not be locked 16 | -------------------------------------------------------------------------------- /features/all/phpcr_namespace_unregister.feature: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpcr/phpcr-shell/e3fe29831482199617d7ed56c774ddb057736d38/features/all/phpcr_namespace_unregister.feature -------------------------------------------------------------------------------- /features/all/phpcr_node_clone.feature: -------------------------------------------------------------------------------- 1 | Feature: Clone a node from a given workspace to the current workspace 2 | In order to clone a node from some workspace to the current workspace 3 | As a user logged into the shell 4 | I want to be able to execute a command which does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the current workspace is "default_1" 9 | And the "session_data.xml" fixtures are loaded 10 | And the current workspace is "default" 11 | And the "cms.xml" fixtures are loaded 12 | 13 | Scenario: Clone node no workspace (symlink) 14 | Given I execute the "node:clone /cms/articles/article1 /cms/clone" command 15 | Then the command should not fail 16 | And I save the session 17 | And there should exist a node at "/cms/clone" 18 | 19 | Scenario: Clone node onto existing node 20 | Given I execute the "node:clone /cms/articles/article1 /cms/test" command 21 | Then the command should not fail 22 | And I save the session 23 | And there should exist a node at "/cms/test/article1" 24 | 25 | Scenario: Clone node 26 | Given I execute the "node:clone /tests_general_base /cms/foobar default_1" command 27 | Then the command should not fail 28 | And I save the session 29 | And there should exist a node at "/cms/foobar" 30 | -------------------------------------------------------------------------------- /features/all/phpcr_node_copy.feature: -------------------------------------------------------------------------------- 1 | Feature: Copy a node from a given workspace to the current workspace 2 | In order to copy a node from some workspace to the current workspace 3 | As a user logged into the shell 4 | I want to be able to execute a command which does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the current workspace is "default_1" 9 | And the "session_data.xml" fixtures are loaded 10 | And the current workspace is "default" 11 | And the "session_data.xml" fixtures are loaded 12 | 13 | Scenario: Copy node in the same workspace 14 | Given I execute the "node:copy /tests_general_base/index.txt /foo" command 15 | Then the command should not fail 16 | And I save the session 17 | And there should exist a node at "/foo" 18 | 19 | Scenario: Copy node from a different workspace 20 | Given I execute the "node:copy /tests_general_base/index.txt /index.txt default_1" command 21 | Then the command should not fail 22 | And there should exist a node at "/index.txt" 23 | 24 | Scenario: Copy node onto existing target 25 | Given I execute the "node:copy /tests_general_base/index.txt /tests_general_base/daniel" command 26 | Then the command should not fail 27 | And I save the session 28 | And there should exist a node at "/tests_general_base/daniel" 29 | -------------------------------------------------------------------------------- /features/all/phpcr_node_corresponding.feature: -------------------------------------------------------------------------------- 1 | Feature: Display the path of any corresponding node in a given workspace 2 | In order to get the path of any corresponding node in a given workspace 3 | As a user that is logged into the shell 4 | I need to be able to do that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the current workspace is "default" 9 | And the "session_data.xml" fixtures are loaded 10 | And the current workspace is "default_1" 11 | And the "session_data.xml" fixtures are loaded 12 | And the current workspace is "default" 13 | 14 | Scenario: Show corresponding nodes 15 | Given the current node is "/tests_general_base/idExample" 16 | And I execute the "node:corresponding . default" command 17 | Then the command should not fail 18 | And I should see the following: 19 | """ 20 | /tests_general_base/idExample 21 | """ 22 | -------------------------------------------------------------------------------- /features/all/phpcr_node_create.feature: -------------------------------------------------------------------------------- 1 | Feature: Create a node 2 | In order to create a new node 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: Create a new node 11 | Given the current node is "/" 12 | And I execute the "node:create testcreate" command 13 | And I save the session 14 | Then the command should not fail 15 | And there should exist a node at "/testcreate" 16 | 17 | Scenario: Create a new node with primary node type 18 | Given the current node is "/" 19 | And I execute the "node:create testfile nt:folder" command 20 | And I save the session 21 | Then the command should not fail 22 | And there should exist a node at "/testfile" 23 | And the primary type of "/testfile" should be "nt:folder" 24 | 25 | Scenario: Create a new node at a non-root current node no matching child type 26 | Given the current node is "/tests_general_base/emptyExample" 27 | And I execute the "node:create testcreate" command 28 | Then the command should fail 29 | And I should see the following: 30 | """ 31 | No matching child node definition found for `testcreate' 32 | """ 33 | 34 | Scenario: Create a new node at a non-root current node 35 | Given the current node is "/tests_general_base" 36 | And I execute the "node:create testcreate nt:folder" command 37 | And I save the session 38 | Then the command should not fail 39 | And there should exist a node at "/tests_general_base/testcreate" 40 | -------------------------------------------------------------------------------- /features/all/phpcr_node_info.feature: -------------------------------------------------------------------------------- 1 | Feature: Show information about node 2 | In order to show some useful information about the current node 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: Show node information 11 | Given the current node is "/tests_general_base" 12 | And I execute the "node:info daniel --no-ansi" command 13 | Then the command should not fail 14 | And I should see the following: 15 | """ 16 | +-------------------+--------------------------------------+ 17 | | UUID | N/A | 18 | | Index | 1 | 19 | | Primary node type | nt:unstructured | 20 | | Mixin node types | | 21 | | Checked out? | N/A | 22 | | Locked? | [ERROR] Not implemented by jackalope | 23 | +-------------------+--------------------------------------+ 24 | """ 25 | -------------------------------------------------------------------------------- /features/all/phpcr_node_lifecycle_follow_transition.feature: -------------------------------------------------------------------------------- 1 | Feature: Follow the given lifecycle transition on the current node 2 | In order to progress the lifecycle state of a node 3 | As a user that is logged into the shell 4 | I need to be able to do 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: Follow lifecycle transition 11 | Given the current node is "/tests_general_base" 12 | And I execute the "node:lifecycle:follow daniel foo" command 13 | Then the command should fail 14 | And I should see the following: 15 | """ 16 | Not implemented 17 | """ 18 | -------------------------------------------------------------------------------- /features/all/phpcr_node_lifecycle_list.feature: -------------------------------------------------------------------------------- 1 | Feature: List the possible lifecycle transitions for the current node 2 | In order to progress the lifecycle state of a node 3 | As a user that is logged into the shell 4 | I need to be able to do 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: List possible lifecycle transitions 11 | Given the current node is "/tests_general_base" 12 | And I execute the "node:lifecycle:list daniel" command 13 | Then the command should fail 14 | And I should see the following: 15 | """ 16 | Not implemented 17 | """ 18 | 19 | -------------------------------------------------------------------------------- /features/all/phpcr_node_mixin_add.feature: -------------------------------------------------------------------------------- 1 | Feature: Add mixin to the current node 2 | In order to add a mixin to the current node 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: Add a mixin to the current node 11 | Given the current node is "/tests_general_base" 12 | And I execute the "node:mixin:add . mix:versionable --no-ansi" command 13 | And I save the session 14 | Then the command should not fail 15 | And the node at "/tests_general_base" should have the mixin "mix:versionable" 16 | -------------------------------------------------------------------------------- /features/all/phpcr_node_mixin_remove.feature: -------------------------------------------------------------------------------- 1 | Feature: Remove mixin to the current node 2 | In order to add a mixin to the current node 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 | And the node at "/tests_general_base" has the mixin "mix:versionable" 10 | 11 | Scenario: Remove a mixin to the current node 12 | Given the current node is "/tests_general_base" 13 | And I execute the "node:mixin:remove . mix:versionable --no-ansi" command 14 | And I save the session 15 | Then the command should not fail 16 | And the node at "/tests_general_base" should not have the mixin "mix:versionable" 17 | -------------------------------------------------------------------------------- /features/all/phpcr_node_move.feature: -------------------------------------------------------------------------------- 1 | Feature: Move a node in the current session 2 | In order to move a single node in the current workspace 3 | As a user logged into the shell 4 | I want to move a node from one path to another 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "cms.xml" fixtures are loaded 9 | 10 | Scenario: Move node 11 | Given I execute the "node:move /cms/test /foobar" command 12 | Then the command should not fail 13 | And I execute the "session:save" command 14 | And there should exist a node at "/foobar" 15 | And there should not exist a node at "/tests_general_base/index.txt" 16 | 17 | Scenario: Move node relative paths 18 | Given the current node is "/cms/test" 19 | And I execute the "node:move . /barfoo" command 20 | Then the command should not fail 21 | And I execute the "session:save" command 22 | And there should exist a node at "/barfoo" 23 | And there should not exist a node at "/tests_general_base/index.txt" 24 | 25 | Scenario: Move onto existing target 26 | Given the current node is "/cms/test" 27 | And I execute the "node:move . /cms/products" command 28 | Then the command should not fail 29 | And I execute the "session:save" command 30 | And there should exist a node at "/cms/products/test" 31 | -------------------------------------------------------------------------------- /features/all/phpcr_node_property_remove.feature: -------------------------------------------------------------------------------- 1 | Feature: Remove a single property at a specified path 2 | In order to remove a single property at a specified path 3 | As a user logged into the shell 4 | I want to be able to run a command with an absolute path to a property and have that property removed 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "cms.xml" fixtures are loaded 9 | 10 | Scenario: Remove a property 11 | Given I execute the "node:property:remove /cms/articles/article1/title" command 12 | Then the command should not fail 13 | And I save the session 14 | And there should not exist a property at "/cms/articles/article1/title" 15 | 16 | Scenario: Try and remove a node 17 | Given I execute the "node:property:remove /tests_general_base" command 18 | Then the command should fail 19 | And I should see the following: 20 | """ 21 | Could not find a property at "/tests_general_base" 22 | """ 23 | -------------------------------------------------------------------------------- /features/all/phpcr_node_property_show.feature: -------------------------------------------------------------------------------- 1 | Feature: Display the contents of a single property 2 | In order to display the contents of a single property 3 | As a user logged into the shell 4 | I want to be able to run a command with an absolute path which displays the contents of a property 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "session_data.xml" fixtures are loaded 9 | 10 | Scenario: Show binary property 11 | Given I execute the "node:property:show /tests_general_base/index.txt/jcr:content/jcr:data" command 12 | Then the command should not fail 13 | And I should see the following: 14 | """ 15 | h1. Chapter 1 Title 16 | 17 | * foo 18 | * bar 19 | ** foo2 20 | ** foo3 21 | * foo0 22 | 23 | || header || bar || 24 | | h | j | 25 | 26 | {code} 27 | hello world 28 | {code} 29 | """ 30 | 31 | Scenario: Show date property 32 | Given I execute the "node:property:show /tests_general_base/index.txt/jcr:content/mydateprop" command 33 | Then the command should not fail 34 | And I should see the following: 35 | """ 36 | 2011-04-21T14:34:20+01:00 37 | """ 38 | 39 | Scenario: Attempt to show a node 40 | Given I execute the "node:property:show /tests_general_base" command 41 | Then the command should fail 42 | And I should see the following: 43 | """ 44 | Could not find property(s) at path 45 | """ 46 | 47 | Scenario: Try to show non-existing property 48 | Given I execute the "node:property:show /this/path/does/not/exist" command 49 | Then the command should fail 50 | And I should see the following: 51 | """ 52 | Could not find property(s) at path 53 | """ 54 | 55 | Scenario: Show properties using wildcard 56 | Given I execute the "node:property:show /tests_general_base/idExample/jcr:*" command 57 | Then the command should not fail 58 | And I should see the following: 59 | """ 60 | /tests_general_base/idExample/jcr:primaryType: nt:file 61 | """ 62 | -------------------------------------------------------------------------------- /features/all/phpcr_node_references.feature: -------------------------------------------------------------------------------- 1 | Feature: Show node references 2 | In order to list which nodes reference the current node 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: List weak references 11 | Given the current node is "/tests_general_base/idExample/jcr:content/weakreference_target" 12 | And I execute the "node:references . --no-ansi" command 13 | Then the command should not fail 14 | And I should see a table containing the following rows: 15 | | Path | Property | Type | 16 | | /tests_general_base/idExample/jcr:content/weakreference_source1 |ref1 | weak | 17 | | /tests_general_base/idExample/jcr:content/weakreference_source2 |ref2 | weak | 18 | 19 | Scenario: List named weak references 20 | Given the current node is "/tests_general_base/idExample/jcr:content/weakreference_target" 21 | And I execute the "node:references . ref2 --no-ansi" command 22 | Then the command should not fail 23 | And I should see a table containing the following rows: 24 | | Path | Property | Type | 25 | | /tests_general_base/idExample/jcr:content/weakreference_source2 |ref2 | weak | 26 | 27 | Scenario: List strong references 28 | Given the current node is "/tests_general_base/idExample" 29 | And I execute the "node:references . --no-ansi" command 30 | Then the command should not fail 31 | And I should see a table containing the following rows: 32 | | Path | Property | Type | 33 | | /tests_general_base/numberPropertyNode/jcr:content | multiref | strong | 34 | | /tests_general_base/numberPropertyNode/jcr:content | ref | strong | 35 | 36 | -------------------------------------------------------------------------------- /features/all/phpcr_node_rename.feature: -------------------------------------------------------------------------------- 1 | Feature: Rename a node 2 | In order to rename a node 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: Rename a node 11 | Given the current node is "/tests_general_base/idExample" 12 | And I execute the "node:rename . foobar" command 13 | And I save the session 14 | Then the command should not fail 15 | And there should exist a node at "/tests_general_base/foobar" 16 | -------------------------------------------------------------------------------- /features/all/phpcr_node_reorder_before.feature: -------------------------------------------------------------------------------- 1 | Feature: Reorder a node 2 | In order to change the order of a node 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: Reorder a node 11 | Given the current node is "/tests_general_base" 12 | And I execute the "node:order-before . emptyExample idExample" command 13 | Then the command should not fail 14 | And I save the session 15 | And there should exist a node at "/tests_general_base/emptyExample" before "/tests_general_base/idExample" 16 | -------------------------------------------------------------------------------- /features/all/phpcr_node_set_primary_type.feature: -------------------------------------------------------------------------------- 1 | Feature: Set the nodes primary type 2 | In order to set the primary type of the current node 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: List the properties and children of the current node 11 | Given the current node is "/tests_general_base" 12 | And I execute the "node:set-primary-type . nt:unstructured --no-ansi" command 13 | Then the command should fail 14 | And I should see the following: 15 | """ 16 | Not implemented 17 | """ 18 | -------------------------------------------------------------------------------- /features/all/phpcr_node_shared_show.feature: -------------------------------------------------------------------------------- 1 | Feature: Show the current nodes shared set 2 | In order to show the shared set to which the current node belongs 3 | As a user that is logged into the shell 4 | I need to be able to do that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the current workspace is "default_1" 9 | And the "cms.xml" fixtures are loaded 10 | And the current workspace is "default" 11 | And I clone node "/cms/articles/article1" from "default_1" to "/foobar" 12 | 13 | Scenario: Show the current nodes shared set 14 | Given the current node is "/foobar" 15 | And I execute the "node:shared:show ." command 16 | Then the command should fail 17 | And I should see the following: 18 | """ 19 | Not implemented 20 | """ 21 | -------------------------------------------------------------------------------- /features/all/phpcr_node_type_list.feature: -------------------------------------------------------------------------------- 1 | Feature: List registered node types 2 | In order to list all of the registered node types 3 | As a user that is logged into the shell 4 | I need to be able to execute a command which does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | 9 | Scenario: List node types 10 | Given I execute the "node-type:list" command 11 | Then the command should not fail 12 | And I should see a table containing the following rows: 13 | | Name | Primary Item Name | Abstract? | Mixin? | Queryable? | 14 | | nt:folder | no | no | yes | yes | 15 | 16 | Scenario: List node types with filter 17 | Given I execute the "node-type:list mix.*" command 18 | Then the command should not fail 19 | And I should see a table containing the following rows: 20 | | Name | Primary Item Name | Abstract? | Mixin? | Queryable? | 21 | | mix:created | | no | yes | yes | 22 | -------------------------------------------------------------------------------- /features/all/phpcr_node_type_load.feature: -------------------------------------------------------------------------------- 1 | Feature: Load a CND file 2 | In order to load a node type definition from a CND file 3 | As a user that is logged into the shell 4 | I need to be able to execute a command which does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the file "NodeType.cnd" contains the contents of "example.cnd" 9 | 10 | Scenario: Attempt to load a non-existing file 11 | Given I execute the "node-type:load notexists.cnd" command 12 | Then the command should fail 13 | And I should see the following: 14 | """ 15 | The CND file "notexists.cnd" does not exist 16 | """ 17 | 18 | Scenario: Load the given node type from a file and allow updating 19 | Given I execute the "node-type:load NodeType.cnd --update" command 20 | Then the command should not fail 21 | And there should exist a node type called "ns:NodeType" 22 | -------------------------------------------------------------------------------- /features/all/phpcr_node_type_show.feature: -------------------------------------------------------------------------------- 1 | Feature: Show a node type 2 | In order to show the CND definition of a node type 3 | As a user that is logged into the shell 4 | I need to be able to execute 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: Execute the note-type show command 11 | Given I execute the "node-type:show nt:unstructured" command 12 | Then the command should not fail 13 | And I should see the following: 14 | """ 15 | [nt:unstructured] > nt:base 16 | orderable query 17 | - * 18 | jcr.operator.equal.to', 'jcr.operator.not.equal.to', 'jcr.operator.greater.than', 'jcr.operator.greater.than.or.equal.to', 'jcr.operator.less.than', 'jcr.operator.less.than.or.equal.to', 'jcr.operator.like 19 | - * 20 | multiple jcr.operator.equal.to', 'jcr.operator.not.equal.to', 'jcr.operator.greater.than', 'jcr.operator.greater.than.or.equal.to', 'jcr.operator.less.than', 'jcr.operator.less.than.or.equal.to', 'jcr.operator.like 21 | + * (nt:base) 22 | = nt:unstructured 23 | VERSION sns 24 | """ 25 | 26 | Scenario: Execute the note-type show command 27 | Given I execute the "node-type:show nt:not-exist" command 28 | Then the command should fail 29 | And I should see the following: 30 | """ 31 | The node type "nt:not-exist" does not exist 32 | """ 33 | -------------------------------------------------------------------------------- /features/all/phpcr_node_type_unregister.feature: -------------------------------------------------------------------------------- 1 | Feature: Unregister a node type 2 | In order to unregister a node type 3 | As a user that is logged into the shell 4 | I need to be able to do that 5 | 6 | # This is not currently implemented by Jackrabbit 7 | 8 | Background: 9 | Given that I am logged in as "testuser" 10 | 11 | Scenario: Unregister a node type 12 | Given the "example.cnd" node type is loaded 13 | And I execute the "node-type:unregister ns:NodeType" command 14 | Then the command should fail 15 | 16 | Scenario: Attempt to unregister a non-registered node type 17 | Given the "example.cnd" node type is loaded 18 | And I execute the "node-type:unregister ns:NodeTypefoobar" command 19 | Then the command should fail 20 | And I should see the following: 21 | """ 22 | NodeType not found 23 | """ 24 | -------------------------------------------------------------------------------- /features/all/phpcr_node_update.feature: -------------------------------------------------------------------------------- 1 | Feature: Update the current node from the node to which it corresponds in the given workspace 2 | In order to update the current node from the node to which it corresponds in the given workspace 3 | As a user that is logged into the shell 4 | I need to be able to do that 5 | 6 | Background: 7 | Given the current workspace is "default_1" 8 | And the "cms.xml" fixtures are loaded 9 | And I set the value of property "title" on node "/cms/articles/article1" to "this is a test" 10 | And the current workspace is "default" 11 | And I clone node "/cms/articles/article1" from "default_1" to "/foobar" 12 | 13 | Scenario: Update a node 14 | Given the current node is "/foobar" 15 | And I execute the "node:update . default_1" command 16 | Then the command should not fail 17 | And I save the session 18 | And the node at "/foobar" should have the property "title" with value "this is a test" 19 | -------------------------------------------------------------------------------- /features/all/phpcr_query.feature: -------------------------------------------------------------------------------- 1 | Feature: Execute a query 2 | In order to run an SQL query 3 | As a user logged into the shell 4 | I want to execute a commad that 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: Execute query 11 | Given I execute the "query 'SELECT a.[jcr:createdBy] FROM [nt:file] AS a'" command 12 | Then the command should not fail 13 | And I should see a table containing the following rows: 14 | | a.jcr:createdBy | 15 | | admin | 16 | 17 | Scenario: Execute query invalid language 18 | Given I execute the "query 'SELECT * FROM [nt:unstructured]' --language=FRENCH" command 19 | Then the command should fail 20 | And I should see the following: 21 | """ 22 | "FRENCH" is an invalid query language, valid query languages are: 23 | """ 24 | And I should see the following: 25 | """ 26 | JCR-SQL2 27 | """ 28 | 29 | Scenario: Execute query with language 30 | Given I execute the "query '/jcr:root/nodes' --language=xpath" command 31 | Then the command should not fail 32 | 33 | Scenario: Execute query with no query 34 | Given I execute the "query --language=xpath" command 35 | Then the command should fail 36 | 37 | Scenario: Execute query by selecting date property 38 | Given I execute the "query --limit=1 'SELECT [jcr:created] FROM [nt:file]'" command 39 | Then the command should not fail 40 | -------------------------------------------------------------------------------- /features/all/phpcr_query_delete.feature: -------------------------------------------------------------------------------- 1 | Feature: Execute a a raw DELETE query in JCR_SQL2 2 | In order to run an DELETE JCR_SQL2 query easily 3 | As a user logged into the shell 4 | I want to simply type the query like in a normal sql shell 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "cms.xml" fixtures are loaded 9 | 10 | Scenario Outline: Execute query 11 | Given I execute the "" command 12 | Then the command should not fail 13 | And there should exist a node at "" 14 | And I save the session 15 | And there should not exist a node at "" 16 | And I should see the following: 17 | """ 18 | 1 row(s) affected 19 | """ 20 | Examples: 21 | | query | path | 22 | | DELETE FROM [nt:unstructured] AS a WHERE localname() = 'product1'; | /cms/products/product1 | 23 | | delete FROM [nt:unstructured] as a where localname() = 'product1'; | /cms/products/product1 | 24 | | DELETE FROM nt:unstructured AS a WHERE localname() = 'product1'; | /cms/products/product1 | 25 | 26 | Scenario: It should fail if a non terminated query is executed 27 | Given I execute the "DELETE FROM [nt:unstructured] WHERE bar = 'product1'" command 28 | Then the command should fail 29 | -------------------------------------------------------------------------------- /features/all/phpcr_query_select.feature: -------------------------------------------------------------------------------- 1 | Feature: Execute a raw query in JCR_SQL2 2 | In order to run an JCR_SQL2 query easily 3 | As a user logged into the shell 4 | I want to simply type the query like in a normal sql shell 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "session_data.xml" fixtures are loaded 9 | 10 | Scenario: Execute query 11 | Given I execute the "SELECT a.[jcr:createdBy], a.[jcr:primaryType] from [nt:folder] AS a WHERE localname() = 'emptyExample';" command 12 | Then the command should not fail 13 | And I should see a table containing the following rows: 14 | | a.jcr:createdBy | a.jcr:primaryType | 15 | | admin | nt:folder | 16 | 17 | Scenario: It should fail if a non terminated query is executed 18 | Given I execute the "SELECT * FROM [nt:unstructured] WHERE bar = 'product1'" command 19 | Then the command should fail 20 | -------------------------------------------------------------------------------- /features/all/phpcr_repository_descriptor_list.feature: -------------------------------------------------------------------------------- 1 | Feature: List Repository Descriptors 2 | In order to show the repositories descriptors 3 | As a logged in user 4 | I want to be able to execute a command which lists the repository descriptors 5 | 6 | Scenario: Listing the descriptors 7 | Given that I am logged in as "testuser" 8 | And I execute the "repository:descriptor:list" command 9 | Then the command should not fail 10 | And I should see a table containing the following rows: 11 | | Key | Value | Standard? | 12 | | jcr.repository.name | Jackrabbit | yes | 13 | | jcr.repository.vendor | Apache Software Foundation | yes | 14 | -------------------------------------------------------------------------------- /features/all/phpcr_retention_hold_add.feature: -------------------------------------------------------------------------------- 1 | Feature: Add a retention hold 2 | In order to add a retention hold on a given node 3 | As a user that is logged into the shell 4 | I need to be able to execute a command which adds a retention hold on a node 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "session_data.xml" fixtures are loaded 9 | 10 | Scenario: Add retention hold 11 | Given I execute the "retention:hold:add /tests_general_base foobar --deep" command 12 | Then the command should fail 13 | And I should see the following: 14 | """ 15 | Unsupported repository operation 16 | """ 17 | -------------------------------------------------------------------------------- /features/all/phpcr_retention_hold_list.feature: -------------------------------------------------------------------------------- 1 | Feature: List retention holds 2 | In order to list the retention holds 3 | As a user that is logged into the shell 4 | I need to be able to see the current retention holds 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "session_data.xml" fixtures are loaded 9 | 10 | Scenario: List retention holds 11 | Given I execute the "retention:hold:list /tests_general_base" command 12 | Then the command should fail 13 | And I should see the following: 14 | """ 15 | Unsupported repository operation 16 | """ 17 | -------------------------------------------------------------------------------- /features/all/phpcr_retention_hold_remove.feature: -------------------------------------------------------------------------------- 1 | Feature: Remove retention hold 2 | In order to remove a retention hold 3 | As a user that is logged into the shell 4 | I need to be able to remove a retention hold 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "session_data.xml" fixtures are loaded 9 | 10 | Scenario: List retention holds 11 | Given I execute the "retention:hold:remove /tests_general_base foobar" command 12 | """ 13 | Unsupported repository operation 14 | """ 15 | -------------------------------------------------------------------------------- /features/all/phpcr_retention_policy_get.feature: -------------------------------------------------------------------------------- 1 | Feature: Show a retention policy for a given node 2 | In order to display the retention policy for a given node 3 | As a user that is logged into the shell 4 | I want to be able to excecute 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: Get retention policy on a given node 11 | Given I execute the "retention:policy:get /tests_general_base" command 12 | """ 13 | Unsupported repository operation 14 | """ 15 | -------------------------------------------------------------------------------- /features/all/phpcr_retention_policy_remove.feature: -------------------------------------------------------------------------------- 1 | Feature: Remove a retention policy for a given node 2 | In order to remove the retention policy for a given node 3 | As a user that is logged into the shell 4 | I want to be able to excecute 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: Remove the retention policy on a given node 11 | Given I execute the "retention:policy:remove /tests_general_base" command 12 | Then the command should fail 13 | """ 14 | Unsupported repository operation 15 | """ 16 | -------------------------------------------------------------------------------- /features/all/phpcr_session_impersonate.feature: -------------------------------------------------------------------------------- 1 | Feature: Impersonate another user 2 | In order to be able to interact with the repository as if I were logged in as another user 3 | As a user logged into the shell 4 | I need to be able to impersonate a different user 5 | 6 | Scenario: Impersonate user 7 | Given that I am logged in as "testuser" 8 | And I execute the "session:impersonate impersonateuser" command 9 | Then the command should fail 10 | And I should see the following: 11 | """ 12 | Not supported 13 | """ 14 | -------------------------------------------------------------------------------- /features/all/phpcr_session_info.feature: -------------------------------------------------------------------------------- 1 | Feature: Show information about current session 2 | In order to find out details about the current session 3 | As a user logged into the shell 4 | I want to execute the "session:info" command to show a list of available information about the session 5 | 6 | Scenario: Run the session info command 7 | Given that I am logged in as "testuser" 8 | And I execute the "session:info" command 9 | Then the command should not fail 10 | And I should see a table containing the following rows: 11 | | Key | Value | 12 | | user id | admin | 13 | | workspace name | default | 14 | -------------------------------------------------------------------------------- /features/all/phpcr_session_namespace_list.feature: -------------------------------------------------------------------------------- 1 | Feature: List all namepsaces mapped to prefixes in the current session 2 | In order to show which prefixes are mapped to which URIs 3 | As a user logged into the shell 4 | I want to run a command which displays a table showing the alias => nameepsace mapping 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | 9 | Scenario: List namespaces 10 | Given I execute the "session:namespace:list" command 11 | Then the command should not fail 12 | And I should see a table containing the following rows: 13 | | Prefix | URI | 14 | | jcr | http://www.jcp.org/jcr/1.0 | 15 | | rep | internal | 16 | -------------------------------------------------------------------------------- /features/all/phpcr_session_namespace_set.feature: -------------------------------------------------------------------------------- 1 | Feature: Set a namespace URI alias 2 | In order to create or update a namespace alias 3 | As a user logged into the shell 4 | I need to be able to run a command which registers an alias with a full URI 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "session_data.xml" fixtures are loaded 9 | 10 | Scenario: Register a new namespace alias 11 | Given I execute the "session:namespace:set foobar http://www.example.com/foobar" command 12 | Then the command should fail 13 | And I should see the following: 14 | """ 15 | TODO: implement session scope remapping of namespaces 16 | """ 17 | -------------------------------------------------------------------------------- /features/all/phpcr_session_refresh.feature: -------------------------------------------------------------------------------- 1 | Feature: Reload the current session 2 | In order to reload the data from the persistatance layer 3 | As a user logged into the shell 4 | I need to be able to run a command which updates the session data 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "session_data.xml" fixtures are loaded 9 | 10 | Scenario: Refesh the session 11 | Given I create a node at "/foobar" 12 | And I execute the "session:refresh" command 13 | Then the command should not fail 14 | And there should exist a node at "/foobar" 15 | 16 | Scenario: Refesh the session and keep changes 17 | Given I create a node at "/foobar" 18 | And I execute the "session:refresh --keep-changes" command 19 | Then the command should not fail 20 | And there should exist a node at "/foobar" 21 | 22 | -------------------------------------------------------------------------------- /features/all/phpcr_session_save.feature: -------------------------------------------------------------------------------- 1 | Feature: Save the current session 2 | In order to persist any changes that have been made in the current session 3 | As a user logged into the shell 4 | I need to be able to run a command which persists the changes made in the current session 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "session_data.xml" fixtures are loaded 9 | 10 | Scenario: Save the session 11 | Given I execute the "session:save" command 12 | Then the command should not fail 13 | -------------------------------------------------------------------------------- /features/all/phpcr_version_checkin.feature: -------------------------------------------------------------------------------- 1 | Feature: Checkin a version 2 | In order to checkin a version of a given absolute path 3 | As a user logged into the shell 4 | I need to be able to execute a command which does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "versionable.xml" fixtures are loaded 9 | 10 | Scenario: Checkin a version of a given node 11 | Given I execute the "version:checkin /tests_version_base/versioned" command 12 | Then the command should not fail 13 | And I should see the following: 14 | """ 15 | Version: 16 | """ 17 | 18 | Scenario: Checkin a non-versionable node 19 | Given I execute the "version:checkin /tests_version_base" command 20 | Then the command should fail 21 | And I should see the following: 22 | """ 23 | Node "/tests_version_base" is not versionable 24 | """ 25 | -------------------------------------------------------------------------------- /features/all/phpcr_version_checkout.feature: -------------------------------------------------------------------------------- 1 | Feature: Checkout a version 2 | In order to modify a versionable node 3 | As a user logged into the shell 4 | I must be able to execute a command which checksout the node 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "versionable.xml" fixtures are loaded 9 | 10 | Scenario: Checkout a a given node 11 | Given I execute the "version:checkout /tests_version_base/versioned" command 12 | Then the command should not fail 13 | And the current node is "/tests_version_base/versioned" 14 | And I execute the "node:info ." command 15 | Then I should see the following: 16 | """ 17 | | Checked out? | yes 18 | """ 19 | 20 | 21 | Scenario: Checkout a non-versionable node 22 | Given I execute the "version:checkout /tests_version_base" command 23 | Then the command should fail 24 | And I should see the following: 25 | """ 26 | Node "/tests_version_base" is not versionable 27 | """ 28 | -------------------------------------------------------------------------------- /features/all/phpcr_version_checkpoint.feature: -------------------------------------------------------------------------------- 1 | Feature: Checkpoint 2 | In order to commit the version status of a node and checkit out again 3 | As a user logged into the shell 4 | I want to be able to execute a command which does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "versionable.xml" fixtures are loaded 9 | 10 | Scenario: Checkpoint a a given node 11 | Given I execute the following commands: 12 | | cd /tests_version_base/versioned | 13 | | node:property:set foo bar | 14 | | session:save | 15 | | version:checkpoint /tests_version_base/versioned | 16 | | node:property:set foo baz | 17 | | session:save | 18 | | version:checkpoint /tests_version_base/versioned | 19 | Then the command should not fail 20 | And I should see the following: 21 | """ 22 | Version: 1.1 23 | """ 24 | And I execute the "node:info ." command 25 | Then I should see the following: 26 | """ 27 | | Checked out? | yes 28 | """ 29 | 30 | Scenario: Checkpoint a non versionable node 31 | Given I execute the "version:checkpoint /tests_version_base" command 32 | Then the command should fail 33 | And I should see the following: 34 | """ 35 | Node "/tests_version_base" is not versionable 36 | """ 37 | -------------------------------------------------------------------------------- /features/all/phpcr_version_history.feature: -------------------------------------------------------------------------------- 1 | Feature: Node Version History 2 | In order to see the version history of a given node 3 | As a user logged into the shell 4 | I want to be able to execute a command which does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "versionable.xml" fixtures are loaded 9 | 10 | Scenario: Show history for a node 11 | When I execute the "version:history /tests_version_base/versioned" command 12 | Then the command should not fail 13 | And I should see a table containing the following rows: 14 | | Name | Created | 15 | 16 | Scenario: History on a non versionable node 17 | When I execute the "version:history /tests_version_base" command 18 | Then the command should fail 19 | And I should see the following: 20 | """ 21 | Node "/tests_version_base" is not versionable 22 | """ 23 | -------------------------------------------------------------------------------- /features/all/phpcr_version_remove.feature: -------------------------------------------------------------------------------- 1 | Feature: Remove node version 2 | In order to remove a version of a node 3 | As a user logged into the shell 4 | I want to be able to execute a command which does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "versionable.xml" fixtures are loaded 9 | 10 | Scenario: Checkout a a given node 11 | When I execute the following commands: 12 | | cd /tests_version_base/versioned | 13 | | version:checkout /tests_version_base/versioned | 14 | | node:property:set foo baz | 15 | | session:save | 16 | | version:checkin /tests_version_base/versioned | 17 | | version:checkout /tests_version_base/versioned | 18 | | node:property:set foo bar | 19 | | session:save | 20 | | version:checkin /tests_version_base/versioned | 21 | And I execute the "version:remove /tests_version_base/versioned 1.0" command 22 | Then the command should not fail 23 | And I execute the "version:history /tests_version_base/versioned" command 24 | And I should not see the following: 25 | """ 26 | | 1.0 | 27 | """ 28 | -------------------------------------------------------------------------------- /features/all/phpcr_version_restore.feature: -------------------------------------------------------------------------------- 1 | Feature: Restore a version 2 | In order to revert a node to a given version 3 | As a user logged into the shell 4 | I need to be able to execute a command which restores a given version 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "versionable.xml" fixtures are loaded 9 | 10 | Scenario: Restore node version 11 | When I execute the following commands: 12 | | cd /tests_version_base/versioned | 13 | | node:property:set foo initalbar | 14 | | session:save | 15 | | version:checkpoint /tests_version_base/versioned | 16 | | node:property:set foo baz | 17 | | session:save | 18 | | version:checkpoint /tests_version_base/versioned | 19 | And I execute the "version:restore /tests_version_base/versioned 1.0" command 20 | Then the command should not fail 21 | And I execute the "ls" command 22 | Then I should see the following: 23 | """ 24 | | foo | STRING (9) | initalbar 25 | """ 26 | -------------------------------------------------------------------------------- /features/cli/doctrine-dbal.feature: -------------------------------------------------------------------------------- 1 | Feature: Connect to a doctrine dbal repository 2 | In order to use the jackalope doctrine-dbal repository 3 | As a user 4 | I need to be able to connect to it 5 | 6 | Background: 7 | Given I initialize doctrine dbal 8 | 9 | Scenario: Connect to doctrine-dbal session 10 | Given I run PHPCR shell with "--transport=doctrine-dbal --db-driver=pdo_sqlite --db-path=./app.sqlite --command='ls'" 11 | Then the command should not fail 12 | 13 | Scenario: Connect to doctrine-dbal session create a new profile 14 | Given I run PHPCR shell with "--transport=doctrine-dbal --db-driver=pdo_sqlite --db-path=./app.sqlite --profile=new --no-interaction --command='ls'" 15 | Then the command should not fail 16 | 17 | Scenario: Connect to an existing profile 18 | Given the following profile "phpcrtest" exists: 19 | """ 20 | transport: 21 | name: doctrine-dbal 22 | db_name: phpcrtest 23 | db_path: app.sqlite 24 | db_driver: pdo_sqlite 25 | phpcr: 26 | workspace: default 27 | username: admin 28 | password: admin 29 | """ 30 | And I run PHPCR shell with "--profile=phpcrtest --no-interaction --command='ls'" 31 | Then the command should not fail 32 | -------------------------------------------------------------------------------- /features/fixtures/example.cnd: -------------------------------------------------------------------------------- 1 | 2 | 3 | [ns:NodeType] > nt:unstructured 4 | orderable query 5 | -------------------------------------------------------------------------------- /features/fixtures/files/phpcrlogos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpcr/phpcr-shell/e3fe29831482199617d7ed56c774ddb057736d38/features/fixtures/files/phpcrlogos.png -------------------------------------------------------------------------------- /features/fixtures/jackalope-doctrine-dbal-cli-config.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | $dbConn = \Doctrine\DBAL\DriverManager::getConnection([ 14 | 'driver' => 'pdo_sqlite', 15 | 'dbname' => 'test', 16 | 'path' => __DIR__.'/app.sqlite', 17 | ]); 18 | 19 | /* 20 | * configuration 21 | */ 22 | $workspace = 'default'; // phpcr workspace to use 23 | $user = 'admin'; 24 | $pass = 'admin'; 25 | 26 | $factory = new \Jackalope\RepositoryFactoryDoctrineDBAL(); 27 | $repository = $factory->getRepository(['jackalope.doctrine_dbal_connection' => $dbConn]); 28 | 29 | $credentials = new \PHPCR\SimpleCredentials($user, $pass); 30 | 31 | /* only create a session if this is not about the server control command */ 32 | if (isset($argv[1]) 33 | && $argv[1] != 'jackalope:init:dbal' 34 | && $argv[1] != 'list' 35 | && $argv[1] != 'help' 36 | ) { 37 | $session = $repository->login($credentials, $workspace); 38 | 39 | $helperSet = new \Symfony\Component\Console\Helper\HelperSet([ 40 | 'dialog' => new \Symfony\Component\Console\Helper\DialogHelper(), 41 | 'phpcr' => new \PHPCR\Util\Console\Helper\PhpcrHelper($session), 42 | 'phpcr_console_dumper' => new \PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper(), 43 | ]); 44 | } elseif (isset($argv[1]) && $argv[1] == 'jackalope:init:dbal') { 45 | // special case: the init command needs the db connection, but a session is impossible if the db is not yet initialized 46 | $helperSet = new \Symfony\Component\Console\Helper\HelperSet([ 47 | 'connection' => new \Jackalope\Tools\Console\Helper\DoctrineDbalHelper($dbConn), 48 | ]); 49 | } 50 | -------------------------------------------------------------------------------- /features/shell/shell_alias.feature: -------------------------------------------------------------------------------- 1 | Feature: Command aliases 2 | In order to be more effective when using the shell 3 | As a user 4 | I want to be able to use the default command aliases 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And the "cms.xml" fixtures are loaded 9 | 10 | Scenario: Execute an alias with a quoted string 11 | Given I execute the "ls 'cms/articles/Title with Spaces'" command 12 | Then the command should not fail 13 | 14 | 15 | Scenario Outline: Execute an alias 16 | Given I execute the "" command 17 | Then the command should not fail 18 | 19 | Examples: 20 | | command | 21 | | select * from [nt:unstructured]; | 22 | | cd cms | 23 | | rm cms | 24 | | mv cms smc | 25 | | ls | 26 | | ls cms | 27 | | ln cms/articles cms/test/foobar | 28 | | cat cms/articles/article1/title | 29 | 30 | 31 | Scenario: List aliases 32 | Given I execute the "shell:alias:list" command 33 | Then the command should not fail 34 | And I should see a table containing the following rows: 35 | | Alias | Command | 36 | | cd | shell:path:change | 37 | | ls | node:list | 38 | -------------------------------------------------------------------------------- /features/shell/shell_autocomplete.feature: -------------------------------------------------------------------------------- 1 | Feature: Path autocompletion 2 | In order to navigate the tree structure precisely and quickly 3 | As a user logged into the shell 4 | I need to be able to be able to invoke auto-completion 5 | 6 | -------------------------------------------------------------------------------- /features/shell/shell_clear.feature: -------------------------------------------------------------------------------- 1 | Feature: clear the screen 2 | In order to clear the screen 3 | As a user 4 | I want to be able to execute a command which does that. 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | 9 | Scenario: Execute the shell clear command 10 | Given I execute the "shell:clear" command 11 | Then the command should not fail 12 | -------------------------------------------------------------------------------- /features/shell/shell_config_init.feature: -------------------------------------------------------------------------------- 1 | Feature: Initialize a new local configuration 2 | In order to create a default configuration 3 | As a user 4 | I want to be able to execute a command which does that 5 | 6 | Scenario: Initialize configuration 7 | Given I execute the "shell:config:init --no-ansi --no-interaction" command 8 | Then the command should not fail 9 | And I should see the following: 10 | """ 11 | alias.yml 12 | """ 13 | -------------------------------------------------------------------------------- /features/shell/shell_config_reload.feature: -------------------------------------------------------------------------------- 1 | Feature: Reload the configuration 2 | In order to reload the configuration 3 | As a user 4 | I want to be able to execute a command which does that 5 | 6 | Scenario: Reload configuration 7 | Given I execute the "shell:config:reload" command 8 | Then the command should not fail 9 | -------------------------------------------------------------------------------- /features/shell/shell_exit.feature: -------------------------------------------------------------------------------- 1 | Feature: Exit the shell 2 | In order to quit this damned shell 3 | As a user 4 | I want to be able to execute a command which does that. 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | 9 | Scenario: Make a change and attempt to exist (default to no exit) 10 | Given I execute the "node:create foo" command 11 | And I execute the "shell:exit --no-interaction" command 12 | Then the command should not fail 13 | -------------------------------------------------------------------------------- /features/shell/shell_path_change.feature: -------------------------------------------------------------------------------- 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" 27 | -------------------------------------------------------------------------------- /features/shell/shell_profile_show.feature: -------------------------------------------------------------------------------- 1 | Feature: Show the profile 2 | In order to inspect the current profile 3 | As a user 4 | I need to be able to execute a command that does that 5 | 6 | Scenario: Dump config 7 | Given I execute the "shell:profile:show --no-ansi --no-interaction" command 8 | Then the command should not fail 9 | And I should see the following: 10 | """ 11 | | name | jackrabbit | 12 | """ 13 | 14 | -------------------------------------------------------------------------------- /features/standalone/phpcr_session_login.feature: -------------------------------------------------------------------------------- 1 | @standlone 2 | Feature: Login to the session 3 | In order to reconnect as a different user from a session 4 | As a user logged into the shell 5 | I need to be able to execute a command which does that 6 | 7 | Background: 8 | Given that I am logged in as "testuser" 9 | 10 | Scenario: Login unauthorized (not existing) 11 | Given I execute the "session:login foobar barfoo" command 12 | Then the command should fail 13 | And I should see the following: 14 | """ 15 | Unauthorized 16 | """ 17 | 18 | Scenario: Login existing 19 | Given I execute the "session:login admin admin" command 20 | Then the command should not fail 21 | 22 | Scenario: Login existing 23 | Given I execute the "session:login admin admin default_1" command 24 | Then the command should not fail 25 | And I execute the "session:info" command 26 | Then I should see the following: 27 | """ 28 | default_1 29 | """ 30 | -------------------------------------------------------------------------------- /features/standalone/phpcr_session_logout.feature: -------------------------------------------------------------------------------- 1 | Feature: Logout of the session 2 | In order to disconnect from the session 3 | As a user logged into the shell 4 | I need to be able to disconnect from the session 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | 9 | Scenario: Logout 10 | Given I execute the "session:logout" command 11 | Then the command should not fail 12 | And I should not be logged into the session 13 | -------------------------------------------------------------------------------- /features/standalone/phpcr_workspace_create.feature: -------------------------------------------------------------------------------- 1 | Feature: Create a new workspace 2 | In order to create a new workspace 3 | As a user logged into the shell 4 | I want to be able to execute a command which does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | 9 | # Jackrabbit does not allow dropping workspaces, so we cannot reliably 10 | # test creating workspaces. 11 | # 12 | # Scenario: Create a workspace 13 | # Given I execute the "workspace:create footest" command 14 | # Then the command should not fail 15 | # And there should exist a workspace called "test" 16 | -------------------------------------------------------------------------------- /features/standalone/phpcr_workspace_delete.feature: -------------------------------------------------------------------------------- 1 | Feature: Delete a workspace 2 | In order to delete a new workspace 3 | As a user logged into the shell 4 | I want to be able to execute a command which does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | 9 | Scenario: Delete a workspace 10 | Given there exists a workspace "test" 11 | And I execute the "workspace:delete test" command 12 | Then the command should fail 13 | And I should see the following: 14 | """ 15 | Can not delete a workspace as jackrabbit can not do it 16 | """ 17 | -------------------------------------------------------------------------------- /features/standalone/phpcr_workspace_list.feature: -------------------------------------------------------------------------------- 1 | Feature: List workspaces 2 | In order to list the accessible workspaces 3 | As a user logged into the shell 4 | I want to execute a commad that does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | 9 | Scenario: List workspaces 10 | Given I execute the "workspace:list" command 11 | Then the command should not fail 12 | And I should see a table containing the following rows: 13 | | Name | 14 | | default | 15 | -------------------------------------------------------------------------------- /features/standalone/phpcr_workspace_namespace_list.feature: -------------------------------------------------------------------------------- 1 | Feature: List workspace namespaces and their prefixes 2 | In order to list the workspaces namespaces and corresponding prefixes 3 | As a user logged into the shell 4 | I should be able to execute 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: List namespaces 11 | Given I execute the "workspace:namespace:list" command 12 | Then the command should not fail 13 | And I should see a table containing the following rows: 14 | | Prefix | URI | 15 | | jcr | http://www.jcp.org/jcr/1.0 | 16 | | sv | http://www.jcp.org/jcr/sv/1.0 | 17 | | nt | http://www.jcp.org/jcr/nt/1.0 | 18 | -------------------------------------------------------------------------------- /features/standalone/phpcr_workspace_namespace_register.feature: -------------------------------------------------------------------------------- 1 | Feature: Register a namespace on the workspace 2 | In order to register a namespace in the current workspace 3 | As a user logged into the shell 4 | I should be able to execute a command which does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | 9 | # We cannot test namespace registration because jackrabbit does not support 10 | # namespace unregistration, so we simply try doing something which provokes 11 | # to throw an exception. 12 | Scenario: Attemp to register a default namespace 13 | Given I execute the "workspace:namespace:register foo http\://www.jcp.org/jcr/nt/1.0" command 14 | Then the command should fail 15 | And I should see the following: 16 | """ 17 | Can not change default namespace 18 | """ 19 | -------------------------------------------------------------------------------- /features/standalone/phpcr_workspace_namespace_unregister.feature: -------------------------------------------------------------------------------- 1 | Feature: Unregister a namespace on the workspace 2 | In order to unregister a namespace in the current workspace 3 | As a user logged into the shell 4 | I should be able to execute a command which does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | 9 | # We cannot test namespace registration because jackrabbit does not support 10 | # namespace unregistration, so we simply try doing something which provokes 11 | # to throw an exception. 12 | Scenario: Attemp to unregister a default namespace 13 | Given I execute the "workspace:namespace:unregister internal" command 14 | Then the command should fail 15 | And I should see the following: 16 | """ 17 | Unregistering namespace not supported by jackrabbit backend 18 | """ 19 | -------------------------------------------------------------------------------- /features/standalone/phpcr_workspace_use.feature: -------------------------------------------------------------------------------- 1 | Feature: Switch to given workspace 2 | In order to change the current workspace 3 | As a user logged into the shell 4 | I want to execute a commad that does that 5 | 6 | Background: 7 | Given that I am logged in as "testuser" 8 | And there exists a workspace "foobar" 9 | 10 | Scenario: List workspaces 11 | Given I execute the "workspace:use foobar" command 12 | Then the command should not fail 13 | And I execute the "session:info" command 14 | Then I should see the following: 15 | """ 16 | foobar 17 | """ 18 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | ./tests 12 | 13 | 14 | 15 | 16 | 17 | . 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Config/ConfigManagerSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Config; 14 | 15 | use PhpSpec\ObjectBehavior; 16 | use Prophecy\Argument; 17 | use Symfony\Component\Filesystem\Filesystem; 18 | 19 | class ConfigManagerSpec extends ObjectBehavior 20 | { 21 | public function let( 22 | Filesystem $filesystem 23 | ) { 24 | $this->beConstructedWith($filesystem); 25 | } 26 | 27 | public function it_is_initializable() 28 | { 29 | $this->shouldHaveType('PHPCR\Shell\Config\ConfigManager'); 30 | } 31 | 32 | public function it_should_have_a_method_to_get_the_users_config_directory() 33 | { 34 | putenv('PHPCRSH_HOME=/home/foobar'); 35 | $this->getConfigDir()->shouldReturn('/home/foobar'); 36 | } 37 | 38 | public function it_should_be_able_to_parse_a_config_file_and_return_the_config_as_an_array( 39 | Filesystem $filesystem 40 | ) { 41 | $dir = __DIR__.'/fixtures/config'; 42 | putenv('PHPCRSH_HOME='.$dir); 43 | $filesystem->exists(Argument::any())->willReturn(true); 44 | 45 | $this->getConfig('alias')->offsetGet('foobar')->shouldReturn('barfoo'); 46 | $this->getConfig('alias')->offsetGet('barfoo')->shouldReturn('foobar'); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Config/ConfigSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Config; 14 | 15 | use PhpSpec\ObjectBehavior; 16 | 17 | class ConfigSpec extends ObjectBehavior 18 | { 19 | public function it_is_initializable() 20 | { 21 | $this->shouldHaveType('PHPCR\Shell\Config\Config'); 22 | } 23 | 24 | public function let() 25 | { 26 | $this->beConstructedWith([ 27 | 'foo' => 'bar', 28 | 'bar' => [ 29 | 'boo' => 'baz', 30 | ], 31 | ]); 32 | } 33 | 34 | public function it_should_be_able_to_access_data_values() 35 | { 36 | $this['foo']->shouldReturn('bar'); 37 | } 38 | 39 | public function it_should_be_able_to_access_nested_config() 40 | { 41 | $this['bar']['boo']->shouldReturn('baz'); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Config/ProfileSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Config; 14 | 15 | use PhpSpec\ObjectBehavior; 16 | 17 | class ProfileSpec extends ObjectBehavior 18 | { 19 | public function let() 20 | { 21 | $this->beConstructedWith( 22 | 'foobar' 23 | ); 24 | } 25 | 26 | public function it_is_initializable() 27 | { 28 | $this->shouldHaveType('PHPCR\Shell\Config\Profile'); 29 | } 30 | 31 | public function it_has_a_method_to_set_config( 32 | ) { 33 | $this->set('transport', []); 34 | } 35 | 36 | public function it_has_a_method_to_get_config() 37 | { 38 | $this->set('transport', [ 39 | 'foo' => 'bar', 40 | ]); 41 | 42 | $this->get('transport')->shouldHaveType('PHPCR\Shell\Config\Config'); 43 | 44 | $this->get('transport', 'foo')->shouldReturn('bar'); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Config/fixtures/config/alias.yml: -------------------------------------------------------------------------------- 1 | foobar: barfoo 2 | barfoo: foobar 3 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Config/profiles/one.yml: -------------------------------------------------------------------------------- 1 | transport: 2 | name: foobar 3 | bar_foo: barfoo 4 | foo_bar: foobar 5 | phpcr: 6 | username: username 7 | password: password 8 | workspace: default 9 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Config/profiles/two.yml: -------------------------------------------------------------------------------- 1 | transport: daadoo 2 | dar_boo: darboo 3 | boo_dar: boodar 4 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Console/Application/EmbeddedApplicationSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Console\Application; 14 | 15 | use PHPCR\Shell\DependencyInjection\Container; 16 | use PhpSpec\ObjectBehavior; 17 | 18 | class EmbeddedApplicationSpec extends ObjectBehavior 19 | { 20 | public function let( 21 | Container $container 22 | ) { 23 | $this->beConstructedWith($container); 24 | } 25 | 26 | public function it_is_initializable() 27 | { 28 | $this->shouldHaveType('PHPCR\Shell\Console\Application\EmbeddedApplication'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Console/Application/ShellApplicationSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Console\Application; 14 | 15 | use PHPCR\Shell\PhpcrShell; 16 | use PhpSpec\ObjectBehavior; 17 | use Symfony\Component\DependencyInjection\ContainerInterface; 18 | 19 | class ShellApplicationSpec extends ObjectBehavior 20 | { 21 | public function let( 22 | ContainerInterface $container 23 | ) { 24 | $this->beConstructedWith($container, PhpcrShell::MODE_EMBEDDED_COMMAND); 25 | } 26 | 27 | public function it_is_initializable() 28 | { 29 | $this->shouldHaveType('PHPCR\Shell\Console\Application\ShellApplication'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Console/Helper/EditorHelperSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Console\Helper; 14 | 15 | use PhpSpec\ObjectBehavior; 16 | 17 | class EditorHelperSpec extends ObjectBehavior 18 | { 19 | public function it_is_initializable() 20 | { 21 | $this->shouldHaveType('PHPCR\Shell\Console\Helper\EditorHelper'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Console/Helper/NodeHelperSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Console\Helper; 14 | 15 | use PHPCR\NodeInterface; 16 | use PhpSpec\ObjectBehavior; 17 | 18 | class NodeHelperSpec extends ObjectBehavior 19 | { 20 | public function it_is_initializable() 21 | { 22 | $this->shouldHaveType('PHPCR\Shell\Console\Helper\NodeHelper'); 23 | } 24 | 25 | public function it_should_provide_a_method_to_determine_if_a_node_has_a_given_mixin( 26 | NodeInterface $node 27 | ) { 28 | $node->isNodeType('mixin1')->willReturn(true); 29 | $node->isNodeType('mixin2')->willReturn(false); 30 | } 31 | 32 | public function it_should_provide_a_method_to_determine_if_a_node_is_versionable( 33 | NodeInterface $nodeVersionable, 34 | NodeInterface $nodeNotVersionable 35 | ) { 36 | $nodeNotVersionable->getPath()->willReturn('foobar'); 37 | $nodeVersionable->isNodeType('mix:versionable')->willReturn(true); 38 | $nodeNotVersionable->isNodeType('mix:versionable')->willReturn(false); 39 | $this->assertNodeIsVersionable($nodeVersionable)->shouldReturn(null); 40 | 41 | try { 42 | $this->assertNodeIsVersionable($nodeNotVersionable); 43 | } catch (\OutOfBoundsException $e) { 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Console/Helper/PathHelperSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Console\Helper; 14 | 15 | use PhpSpec\ObjectBehavior; 16 | 17 | class PathHelperSpec extends ObjectBehavior 18 | { 19 | public function it_is_initializable() 20 | { 21 | $this->shouldHaveType('PHPCR\Shell\Console\Helper\PathHelper'); 22 | } 23 | 24 | public function it_has_a_method_to_provide_the_parent_path_for_a_given_path() 25 | { 26 | $this->getParentPath('/foo/bar')->shouldReturn('/foo'); 27 | } 28 | 29 | public function it_has_a_method_to_get_the_node_name_of_a_given_path() 30 | { 31 | $this->getNodeName('/foo/bar')->shouldReturn('bar'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Console/Helper/RepositoryHelperSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Console\Helper; 14 | 15 | use PHPCR\RepositoryInterface; 16 | use PHPCR\Shell\Phpcr\SessionManager; 17 | use PhpSpec\ObjectBehavior; 18 | 19 | class RepositoryHelperSpec extends ObjectBehavior 20 | { 21 | public function let( 22 | SessionManager $sessionManager 23 | ) { 24 | $this->beConstructedWith($sessionManager); 25 | } 26 | 27 | public function it_is_initializable() 28 | { 29 | $this->shouldHaveType('PHPCR\Shell\Console\Helper\RepositoryHelper'); 30 | } 31 | 32 | public function it_provides_a_method_to_say_if_a_descriptor_exists_or_not( 33 | SessionManager $sessionManager, 34 | RepositoryInterface $repository 35 | ) { 36 | $sessionManager->getRepository()->willReturn($repository); 37 | $repository->getDescriptorKeys()->willReturn([ 38 | 'foo', 'bar', 39 | ]); 40 | $repository->getDescriptor('foo')->willReturn('foo'); 41 | $repository->getDescriptor('bar')->willReturn('foo'); 42 | 43 | $this->hasDescriptor('foo')->shouldReturn(true); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Console/Helper/ResultFormatterHelperSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Console\Helper; 14 | 15 | use PHPCR\Shell\Config\Config; 16 | use PHPCR\Shell\Console\Helper\TextHelper; 17 | use PhpSpec\ObjectBehavior; 18 | 19 | class ResultFormatterHelperSpec extends ObjectBehavior 20 | { 21 | public function let( 22 | TextHelper $textHelper, 23 | Config $config 24 | ) { 25 | $this->beConstructedWith($textHelper, $config); 26 | } 27 | 28 | public function it_is_initializable() 29 | { 30 | $this->shouldHaveType('PHPCR\Shell\Console\Helper\ResultFormatterHelper'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Console/Helper/TextHelperSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Console\Helper; 14 | 15 | use PhpSpec\ObjectBehavior; 16 | 17 | class TextHelperSpec extends ObjectBehavior 18 | { 19 | public function it_is_initializable() 20 | { 21 | $this->shouldHaveType('PHPCR\Shell\Console\Helper\TextHelper'); 22 | } 23 | 24 | public function it_should_truncate_text() 25 | { 26 | $this->truncate('hello this is some text', 5)->shouldReturn('he...'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Console/Input/StringInputSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Console\Input; 14 | 15 | use PhpSpec\ObjectBehavior; 16 | 17 | class StringInputSpec extends ObjectBehavior 18 | { 19 | public function let() 20 | { 21 | $this->beConstructedWith('foobar'); 22 | } 23 | 24 | public function it_is_initializable() 25 | { 26 | $this->shouldHaveType('PHPCR\Shell\Console\Input\StringInput'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Event/ApplicationInitEventSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Event; 14 | 15 | use PhpSpec\ObjectBehavior; 16 | use Symfony\Component\Console\Application; 17 | 18 | class ApplicationInitEventSpec extends ObjectBehavior 19 | { 20 | public function it_is_initializable() 21 | { 22 | $this->shouldHaveType('PHPCR\Shell\Event\ApplicationInitEvent'); 23 | } 24 | 25 | public function let( 26 | Application $application 27 | ) { 28 | $this->beConstructedWith($application); 29 | } 30 | 31 | public function it_will_return_the_application( 32 | Application $application 33 | ) { 34 | $this->getApplication()->shouldReturn($application); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Event/CommandExceptionEventSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Event; 14 | 15 | use PHPCR\Shell\Console\Application\ShellApplication; 16 | use PhpSpec\ObjectBehavior; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class CommandExceptionEventSpec extends ObjectBehavior 20 | { 21 | public function it_is_initializable() 22 | { 23 | $this->shouldHaveType('PHPCR\Shell\Event\CommandExceptionEvent'); 24 | } 25 | 26 | public function let( 27 | \Exception $exception, 28 | ShellApplication $application, 29 | OutputInterface $output 30 | ) { 31 | $this->beConstructedWith($exception, $application, $output); 32 | } 33 | 34 | public function it_should_provide_access_to_event_parameters( 35 | \Exception $exception, 36 | OutputInterface $output 37 | ) { 38 | $this->getException()->shouldReturn($exception); 39 | $this->getOutput()->shouldReturn($output); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Event/ProfileInitEventSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Event; 14 | 15 | use PHPCR\Shell\Config\Profile; 16 | use PhpSpec\ObjectBehavior; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class ProfileInitEventSpec extends ObjectBehavior 21 | { 22 | public function it_is_initializable() 23 | { 24 | $this->shouldHaveType('PHPCR\Shell\Event\ProfileInitEvent'); 25 | } 26 | 27 | public function let( 28 | Profile $profile, 29 | InputInterface $input, 30 | OutputInterface $output 31 | ) { 32 | $this->beConstructedWith( 33 | $profile, 34 | $input, 35 | $output 36 | ); 37 | } 38 | 39 | public function it_should_have_getters( 40 | Profile $profile, 41 | InputInterface $input, 42 | OutputInterface $output 43 | ) { 44 | $this->getProfile()->shouldReturn($profile); 45 | $this->getInput()->shouldReturn($input); 46 | $this->getOutput()->shouldReturn($output); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Phpcr/SessionManagerSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Phpcr; 14 | 15 | use PHPCR\Shell\Config\Profile; 16 | use PHPCR\Shell\Transport\TransportRegistryInterface; 17 | use PhpSpec\ObjectBehavior; 18 | 19 | class SessionManagerSpec extends ObjectBehavior 20 | { 21 | public function let( 22 | Profile $profile, 23 | TransportRegistryInterface $transportRegistry 24 | ) { 25 | $this->beConstructedWith($transportRegistry, $profile); 26 | } 27 | 28 | public function it_is_initializable() 29 | { 30 | $this->shouldHaveType('PHPCR\Shell\Phpcr\SessionManager'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Serializer/NodeNormalizerSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Serializer; 14 | 15 | use PHPCR\NodeInterface; 16 | use PHPCR\PropertyInterface; 17 | use PHPCR\PropertyType; 18 | use PhpSpec\ObjectBehavior; 19 | 20 | class NodeNormalizerSpec extends ObjectBehavior 21 | { 22 | public function it_is_initializable() 23 | { 24 | $this->shouldHaveType('PHPCR\Shell\Serializer\NodeNormalizer'); 25 | } 26 | 27 | public function it_can_normalize_a_node_to_an_array( 28 | NodeInterface $node, 29 | PropertyInterface $p1, 30 | PropertyInterface $p2, 31 | PropertyInterface $p3 32 | ) { 33 | $node->getProperties()->willReturn([ 34 | $p1, $p2, $p3, 35 | ]); 36 | 37 | $p1->getName()->willReturn('my:property.1'); 38 | $p1->getType()->willReturn(PropertyType::STRING); 39 | $p1->getValue()->willReturn('P1 Val'); 40 | $p2->getName()->willReturn('my:property.2'); 41 | $p2->getType()->willReturn(PropertyType::DOUBLE); 42 | $p2->getValue()->willReturn('P2 Val'); 43 | $p3->getName()->willReturn('my:property.3'); 44 | $p3->getType()->willReturn(PropertyType::STRING); 45 | $p3->getValue()->willReturn('P3 Val'); 46 | 47 | $this->normalize($node)->shouldReturn([ 48 | 'my:property.1' => [ 49 | 'type' => 'String', 50 | 'value' => 'P1 Val', 51 | ], 52 | 'my:property.2' => [ 53 | 'type' => 'Double', 54 | 'value' => 'P2 Val', 55 | ], 56 | 'my:property.3' => [ 57 | 'type' => 'String', 58 | 'value' => 'P3 Val', 59 | ], 60 | ]); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Serializer/YamlEncoderSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Serializer; 14 | 15 | use PhpSpec\ObjectBehavior; 16 | 17 | class YamlEncoderSpec extends ObjectBehavior 18 | { 19 | public function it_is_initializable() 20 | { 21 | $this->shouldHaveType('PHPCR\Shell\Serializer\YamlEncoder'); 22 | } 23 | 24 | public function it_should_encode_to_yaml() 25 | { 26 | $data = ['foobar' => 'barfoo', 'barfoo' => 'foobar']; 27 | $this->encode($data, 'yaml')->shouldReturn( 28 | <<<'EOT' 29 | foobar: barfoo 30 | barfoo: foobar 31 | 32 | EOT 33 | ); 34 | } 35 | 36 | public function is_should_decode_yaml() 37 | { 38 | $yaml = <<<'EOT' 39 | foobar: barfoo 40 | barfoo: foobar 41 | EOT; 42 | 43 | $this->decode($yaml, 'yaml')->shouldReturn([ 44 | 'foobar' => 'barfoo', 45 | 'barfoo' => 'foobar', 46 | ]); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Subscriber/AliasSubscriberSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Subscriber; 14 | 15 | use PHPCR\Shell\Config\ConfigManager; 16 | use PHPCR\Shell\Console\Input\StringInput; 17 | use PHPCR\Shell\Event\CommandPreRunEvent; 18 | use PhpSpec\ObjectBehavior; 19 | use Prophecy\Argument; 20 | 21 | class AliasSubscriberSpec extends ObjectBehavior 22 | { 23 | public function it_is_initializable() 24 | { 25 | $this->shouldHaveType('PHPCR\Shell\Subscriber\AliasSubscriber'); 26 | } 27 | 28 | public function let( 29 | ConfigManager $config 30 | ) { 31 | $this->beConstructedWith( 32 | $config 33 | ); 34 | 35 | $config->getConfig('alias')->willReturn([ 36 | 'ls' => 'list:command', 37 | 'mv' => 'move', 38 | ]); 39 | } 40 | 41 | public function it_should_convert_an_aliased_input_into_a_real_command_input( 42 | CommandPreRunEvent $event, 43 | StringInput $input 44 | ) { 45 | $event->getInput()->willReturn($input); 46 | $input->getRawCommand()->willReturn('ls -L5 --children'); 47 | $input->getFirstArgument()->willReturn('ls'); 48 | $event->setInput(Argument::type('PHPCR\Shell\Console\Input\StringInput'))->shouldBeCalled(); 49 | 50 | $this->handleAlias($event)->shouldReturn('list:command -L5 --children'); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Transport/Transport/DoctrineDbalSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Transport\Transport; 14 | 15 | use PhpSpec\ObjectBehavior; 16 | 17 | class DoctrineDbalSpec extends ObjectBehavior 18 | { 19 | public function it_is_initializable() 20 | { 21 | $this->shouldHaveType('PHPCR\Shell\Transport\Transport\DoctrineDbal'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Transport/Transport/JackrabbitSpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Transport\Transport; 14 | 15 | use PhpSpec\ObjectBehavior; 16 | 17 | class JackrabbitSpec extends ObjectBehavior 18 | { 19 | public function it_is_initializable() 20 | { 21 | $this->shouldHaveType('PHPCR\Shell\Transport\Transport\Jackrabbit'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spec/PHPCR/Shell/Transport/TransportRegistrySpec.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace spec\PHPCR\Shell\Transport; 14 | 15 | use PHPCR\Shell\Transport\TransportInterface; 16 | use PhpSpec\ObjectBehavior; 17 | 18 | class TransportRegistrySpec extends ObjectBehavior 19 | { 20 | public function it_is_initializable() 21 | { 22 | $this->shouldHaveType('PHPCR\Shell\Transport\TransportRegistry'); 23 | } 24 | 25 | public function it_can_register_transports( 26 | TransportInterface $transport 27 | ) { 28 | $transport->getName()->willReturn('foobar'); 29 | $this->register($transport); 30 | } 31 | 32 | public function it_can_return_the_names_of_the_transports( 33 | TransportInterface $transport1, 34 | TransportInterface $transport2 35 | ) { 36 | $transport1->getName()->willReturn('transport1'); 37 | $transport2->getName()->willReturn('transport2'); 38 | $this->register($transport1); 39 | $this->register($transport2); 40 | 41 | $this->getTransportNames()->shouldReturn([ 42 | 'transport1', 'transport2', 43 | ]); 44 | } 45 | 46 | public function it_can_return_a_named_transport_object( 47 | TransportInterface $transport 48 | ) { 49 | $transport->getName()->willReturn('test'); 50 | $this->register($transport); 51 | 52 | $this->getTransport('test')->shouldReturn($transport); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Config/Exception/FileExistsException.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Config\Exception; 14 | 15 | class FileExistsException extends \Exception 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Application/EmbeddedApplication.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Application; 14 | 15 | use PHPCR\Shell\Console\Input\StringInput; 16 | use PHPCR\Shell\DependencyInjection\Container; 17 | use PHPCR\Shell\PhpcrShell; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | /** 21 | * Subclass of the full ShellApplication for running as an EmbeddedApplication 22 | * (e.g. from with the DoctrinePhpcrBundle). 23 | * 24 | * @author Daniel Leech 25 | */ 26 | class EmbeddedApplication extends ShellApplication 27 | { 28 | /** 29 | * @param Container $container 30 | */ 31 | public function __construct(Container $container) 32 | { 33 | parent::__construct($container); 34 | $this->setAutoExit(false); 35 | } 36 | 37 | /** 38 | * {@inheritdoc} 39 | */ 40 | public function init() 41 | { 42 | $this->registerPhpcrCommands(); 43 | 44 | if ($this->container->getMode() === PhpcrShell::MODE_EMBEDDED_SHELL) { 45 | $this->registerShellCommands(); 46 | } 47 | } 48 | 49 | /** 50 | * {@inheritdoc} 51 | */ 52 | protected function getDefaultCommand() 53 | { 54 | return $this->container->getMode() === PhpcrShell::MODE_EMBEDDED_SHELL ? 'shell:path:show' : 'list'; 55 | } 56 | 57 | public function runWithStringInput($stringInput, OutputInterface $output) 58 | { 59 | $input = new StringInput($stringInput); 60 | 61 | return $this->run($input, $output); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/BaseCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command; 14 | 15 | use PHPCR\Shell\DependencyInjection\ContainerAwareInterface; 16 | use Symfony\Component\Console\Command\Command; 17 | use Symfony\Component\DependencyInjection\ContainerInterface; 18 | 19 | class BaseCommand extends Command implements ContainerAwareInterface 20 | { 21 | /** 22 | * @var ContainerInterface 23 | */ 24 | private $container; 25 | 26 | public function setContainer(ContainerInterface $container = null): void 27 | { 28 | $this->container = $container; 29 | } 30 | 31 | public function get($serviceId) 32 | { 33 | if (null === $this->container) { 34 | throw new \RuntimeException( 35 | 'Container has not been set on this command' 36 | ); 37 | } 38 | 39 | return $this->container->get($serviceId); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/BasePhpcrCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\Shell\Console\Command\BaseCommand; 16 | 17 | /** 18 | * Base command for all PHPCR action commands. 19 | * 20 | * @author Daniel Leech 21 | */ 22 | class BasePhpcrCommand extends BaseCommand 23 | { 24 | protected $descriptorRequires = []; 25 | protected $descriptorDequires = []; 26 | 27 | public function requiresDescriptor($descriptorKey, $value = null) 28 | { 29 | $this->descriptorRequires[$descriptorKey] = $value; 30 | } 31 | 32 | public function dequiresDescriptor($descriptorKey, $value = null) 33 | { 34 | $this->descriptorDequires[$descriptorKey] = $value; 35 | } 36 | 37 | public function getDescriptorRequires() 38 | { 39 | return $this->descriptorRequires; 40 | } 41 | 42 | public function getDescriptorDequires() 43 | { 44 | return $this->descriptorDequires; 45 | } 46 | 47 | public function isSupported() 48 | { 49 | $repositoryHelper = $this->get('helper.repository'); 50 | foreach ($this->descriptorRequires as $key => $value) { 51 | $has = $repositoryHelper->hasDescriptor($key, $value); 52 | if (!$has) { 53 | return false; 54 | } 55 | } 56 | 57 | foreach ($this->descriptorDequires as $key => $value) { 58 | $has = $repositoryHelper->hasDescriptor($key, $value); 59 | 60 | if ($has) { 61 | return false; 62 | } 63 | } 64 | 65 | return true; 66 | } 67 | 68 | public function getDescriptor() 69 | { 70 | return true; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/BaseQueryCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputInterface; 16 | 17 | class BaseQueryCommand extends BasePhpcrCommand 18 | { 19 | public function getQuery(InputInterface $input) 20 | { 21 | $sql = $input->getRawCommand(); 22 | 23 | if (substr($sql, -1) !== ';') { 24 | throw new \InvalidArgumentException( 25 | 'Queries must be terminated with ";"' 26 | ); 27 | } 28 | 29 | return substr($sql, 0, -1); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/LockRefreshCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\RepositoryInterface; 16 | use Symfony\Component\Console\Input\InputArgument; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class LockRefreshCommand extends BasePhpcrCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('lock:refresh'); 25 | $this->setDescription('Refresh the TTL of the lock of the node at the given path'); 26 | $this->addArgument('path', InputArgument::REQUIRED, 'Path of node containing the lock to be refreshed'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | If this lock's time-to-live is governed by a timer, this command resets 30 | that timer so that the lock does not timeout and expire. 31 | 32 | If this lock's time-to-live is not governed by a timer, then this method 33 | has no effect. 34 | HERE 35 | ); 36 | $this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true); 37 | $this->dequiresDescriptor('jackalope.not_implemented.get_lock'); 38 | } 39 | 40 | public function execute(InputInterface $input, OutputInterface $output): int 41 | { 42 | $session = $this->get('phpcr.session'); 43 | $workspace = $session->getWorkspace(); 44 | $lockManager = $workspace->getLockManager(); 45 | 46 | $path = $input->getArgument('path'); 47 | $nodes = $session->findNodes($path); 48 | 49 | foreach ($nodes as $node) { 50 | $lock = $lockManager->getLock($node->getPath()); 51 | $lock->refresh(); 52 | } 53 | 54 | return 0; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/LockTokenAddCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\RepositoryInterface; 16 | use Symfony\Component\Console\Input\InputArgument; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class LockTokenAddCommand extends BasePhpcrCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('lock:token:add'); 25 | $this->setDescription('Add a lock token to the current session'); 26 | $this->addArgument('lockToken', InputArgument::REQUIRED, 'Lock token'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Adds the specified lock token to the current Session. 30 | 31 | Holding a lock token makes the current Session the owner of the lock 32 | specified by that particular lock token. 33 | HERE 34 | ); 35 | $this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true); 36 | $this->dequiresDescriptor('jackalope.not_implemented.lock_token'); 37 | } 38 | 39 | public function execute(InputInterface $input, OutputInterface $output): int 40 | { 41 | $session = $this->get('phpcr.session'); 42 | $workspace = $session->getWorkspace(); 43 | $lockManager = $workspace->getLockManager(); 44 | $lockToken = $input->getArgument('lockToken'); 45 | 46 | $lockManager->addLockToken($lockToken); 47 | 48 | return 0; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/LockTokenListCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\RepositoryInterface; 16 | use PHPCR\Shell\Console\Helper\Table; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class LockTokenListCommand extends BasePhpcrCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('lock:token:list'); 25 | $this->setDescription('List a lock token to the current session'); 26 | $this->setHelp( 27 | <<<'HERE' 28 | Show a list of previously registered tokens. 29 | 30 | Displays all lock tokens currently held by the 31 | current Session. Note that any such tokens will represent open-scoped 32 | locks, since session-scoped locks do not have tokens. 33 | HERE 34 | ); 35 | $this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true); 36 | $this->dequiresDescriptor('jackalope.not_implemented.lock_token'); 37 | } 38 | 39 | public function execute(InputInterface $input, OutputInterface $output): int 40 | { 41 | $session = $this->get('phpcr.session'); 42 | $workspace = $session->getWorkspace(); 43 | $lockManager = $workspace->getLockManager(); 44 | 45 | $lockTokens = $lockManager->getLockTokens(); 46 | 47 | $table = new Table($output); 48 | $table->setHeaders(['Token']); 49 | 50 | foreach ($lockTokens as $token) { 51 | $table->addRow([$token]); 52 | } 53 | 54 | $table->render($output); 55 | 56 | return 0; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/LockTokenRemoveCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\RepositoryInterface; 16 | use Symfony\Component\Console\Input\InputArgument; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class LockTokenRemoveCommand extends BasePhpcrCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('lock:token:remove'); 25 | $this->setDescription('Remove a lock token to the current session'); 26 | $this->addArgument('lockToken', InputArgument::REQUIRED, 'Lock token'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Removes the specified lock token from the current Session. 30 | HERE 31 | ); 32 | $this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true); 33 | $this->dequiresDescriptor('jackalope.not_implemented.lock_token'); 34 | } 35 | 36 | public function execute(InputInterface $input, OutputInterface $output): int 37 | { 38 | $session = $this->get('phpcr.session'); 39 | $workspace = $session->getWorkspace(); 40 | $lockManager = $workspace->getLockManager(); 41 | $lockToken = $input->getArgument('lockToken'); 42 | 43 | $lockManager->removeLockToken($lockToken); 44 | 45 | return 0; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/LockUnlockCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\RepositoryInterface; 16 | use Symfony\Component\Console\Input\InputArgument; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class LockUnlockCommand extends BasePhpcrCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('lock:unlock'); 25 | $this->setDescription('Unlock the node at the given path'); 26 | $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Removes the lock on the node at path. 30 | 31 | Also removes the properties jcr:lockOwner and jcr:lockIsDeep from that 32 | node. As well, the corresponding lock token is removed from the set of 33 | lock tokens held by the current Session. 34 | 35 | Note that it is possible to unlock a node even if it is checked-in (the 36 | lock-related properties will be changed despite the checked-in status). 37 | HERE 38 | ); 39 | $this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true); 40 | $this->dequiresDescriptor('jackalope.not_implemented.get_lock'); 41 | } 42 | 43 | public function execute(InputInterface $input, OutputInterface $output): int 44 | { 45 | $session = $this->get('phpcr.session'); 46 | $workspace = $session->getWorkspace(); 47 | $lockManager = $workspace->getLockManager(); 48 | 49 | $path = $session->getAbsPath($input->getArgument('path')); 50 | 51 | $lockManager->unlock($path); 52 | 53 | return 0; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/NodeCorrespondingCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class NodeCorrespondingCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('node:corresponding'); 24 | $this->setDescription('Show the path for the current nodes corresponding path in named workspace'); 25 | $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); 26 | $this->addArgument('workspaceName', InputArgument::REQUIRED, 'The name of the workspace'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Returns the absolute path of the node in the specified workspace that 30 | corresponds to this node. 31 | HERE 32 | ); 33 | } 34 | 35 | public function execute(InputInterface $input, OutputInterface $output): int 36 | { 37 | $session = $this->get('phpcr.session'); 38 | $path = $input->getArgument('path'); 39 | $workspaceName = $input->getArgument('workspaceName'); 40 | $currentNode = $session->getNodeByPathOrIdentifier($path); 41 | $correspondingPath = $currentNode->getCorrespondingNodePath($workspaceName); 42 | $output->writeln($correspondingPath); 43 | 44 | return 0; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleListCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\RepositoryInterface; 16 | use Symfony\Component\Console\Input\InputArgument; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class NodeLifecycleListCommand extends BasePhpcrCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('node:lifecycle:list'); 25 | $this->setDescription('Returns the list of valid state transitions for this node.'); 26 | $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Returns the list of valid state transitions for this node. 30 | HERE 31 | ); 32 | 33 | $this->requiresDescriptor(RepositoryInterface::OPTION_LIFECYCLE_SUPPORTED, true); 34 | } 35 | 36 | public function execute(InputInterface $input, OutputInterface $output): int 37 | { 38 | $session = $this->get('phpcr.session'); 39 | $path = $input->getArgument('path'); 40 | $currentNode = $session->getNodeByPathOrIdentifier($path); 41 | $transitions = $currentNode->getAllowedLifecycleTransitions(); 42 | 43 | foreach ($transitions as $transition) { 44 | $output->writeln(''.$transition.''); 45 | } 46 | 47 | return 0; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinAddCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class NodeMixinAddCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('node:mixin:add'); 24 | $this->setDescription('Add the named mixin to the node (can include wildcards)'); 25 | $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); 26 | $this->addArgument('mixinName', InputArgument::REQUIRED, 'The name of the mixin node type to be added'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Adds the mixin node type named mixinName to the node(s) inferred by the path. 30 | 31 | If this node is already of type mixinName (either due to a previously 32 | added mixin or due to its primary type, through inheritance) then this 33 | method has no effect. Otherwise mixinName is added to this node's 34 | jcr:mixinTypes property. 35 | HERE 36 | ); 37 | } 38 | 39 | public function execute(InputInterface $input, OutputInterface $output): int 40 | { 41 | $session = $this->get('phpcr.session'); 42 | $path = $input->getArgument('path'); 43 | $mixinName = $input->getArgument('mixinName'); 44 | 45 | $nodes = $session->findNodes($path); 46 | 47 | foreach ($nodes as $node) { 48 | $node->addMixin($mixinName); 49 | } 50 | 51 | return 0; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinRemoveCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class NodeMixinRemoveCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('node:mixin:remove'); 24 | $this->setDescription('Remove the named mixin to the current node'); 25 | $this->addArgument('path', InputArgument::REQUIRED, 'Path of node (can include wildcards)'); 26 | $this->addArgument('mixinName', InputArgument::REQUIRED, 'The name of the mixin node type to be removeed'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Removes the specified mixin node type from this node and removes 30 | mixinName from this node's jcr:mixinTypes property. 31 | 32 | Both the semantic change in effective node type and the persistence of 33 | the change to the jcr:mixinTypes property occur on persist. 34 | HERE 35 | ); 36 | } 37 | 38 | public function execute(InputInterface $input, OutputInterface $output): int 39 | { 40 | $session = $this->get('phpcr.session'); 41 | $mixinName = $input->getArgument('mixinName'); 42 | $path = $input->getArgument('path'); 43 | 44 | $nodes = $session->findNodes($path); 45 | 46 | foreach ($nodes as $node) { 47 | $node->removeMixin($mixinName); 48 | } 49 | 50 | return 0; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/NodeMoveCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class NodeMoveCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('node:move'); 24 | $this->setDescription('Move a node in the current session'); 25 | $this->addArgument('srcPath', InputArgument::REQUIRED, 'The root of the subgraph to be moved.'); 26 | $this->addArgument('destPath', InputArgument::REQUIRED, 'The location to which the subgraph is to be moved'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Moves the node at srcPath (and its entire subgraph) to the new 30 | location at destPath. 31 | 32 | This is a session-write command and therefor requires a save to dispatch 33 | the change. 34 | HERE 35 | ); 36 | } 37 | 38 | public function execute(InputInterface $input, OutputInterface $output): int 39 | { 40 | $session = $this->get('phpcr.session'); 41 | $srcPath = $input->getArgument('srcPath'); 42 | $destPath = $input->getArgument('destPath'); 43 | 44 | $session->move($srcPath, $destPath); 45 | 46 | return 0; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyRemoveCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\PathNotFoundException; 16 | use Symfony\Component\Console\Input\InputArgument; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class NodePropertyRemoveCommand extends BasePhpcrCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('node:property:remove'); 25 | $this->setDescription('Remove the property at the given absolute path'); 26 | $this->addArgument('absPath', InputArgument::REQUIRED, 'Absolute path to property'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Remove the property from the current session at the given path 30 | HERE 31 | ); 32 | } 33 | 34 | public function execute(InputInterface $input, OutputInterface $output): int 35 | { 36 | $session = $this->get('phpcr.session'); 37 | $absPath = $input->getArgument('absPath'); 38 | 39 | try { 40 | $property = $session->getProperty($absPath); 41 | } catch (PathNotFoundException $e) { 42 | throw new \Exception(sprintf( 43 | 'Could not find a property at "%s"', 44 | $absPath 45 | )); 46 | } 47 | 48 | $property->remove(); 49 | 50 | return 0; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/NodeRenameCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class NodeRenameCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('node:rename'); 24 | $this->setDescription('Rename the node at the current path'); 25 | $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); 26 | $this->addArgument('newName', InputArgument::REQUIRED, 'The name of the node to create'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Renames this node to the specified newName. The ordering (if any) of 30 | this node among it siblings remains unchanged. 31 | 32 | This is a session-write method, meaning that the name change is 33 | dispatched upon session:save. 34 | HERE 35 | ); 36 | } 37 | 38 | public function execute(InputInterface $input, OutputInterface $output): int 39 | { 40 | $session = $this->get('phpcr.session'); 41 | $path = $input->getArgument('path'); 42 | $newName = $input->getArgument('newName'); 43 | $currentNode = $session->getNodeByPathOrIdentifier($path); 44 | $currentNode->rename($newName); 45 | 46 | return 0; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/NodeSetPrimaryTypeCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class NodeSetPrimaryTypeCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('node:set-primary-type'); 24 | $this->setDescription('Set the primary type of the current node'); 25 | $this->addArgument('path', InputArgument::REQUIRED, 'Path of node (can include wildcard)'); 26 | $this->addArgument('nodeTypeName', InputArgument::REQUIRED, 'New primary node type name'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Changes the primary node type of this node to nodeTypeName. 30 | 31 | Also immediately changes this node's jcr:primaryType property 32 | appropriately. 33 | HERE 34 | ); 35 | } 36 | 37 | public function execute(InputInterface $input, OutputInterface $output): int 38 | { 39 | $session = $this->get('phpcr.session'); 40 | $path = $input->getArgument('path'); 41 | $nodeTypeName = $input->getArgument('nodeTypeName'); 42 | 43 | $nodes = $session->findNodes($path); 44 | 45 | foreach ($nodes as $node) { 46 | $node->setPrimaryType($nodeTypeName); 47 | } 48 | 49 | return 0; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedShowCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\RepositoryInterface; 16 | use Symfony\Component\Console\Input\InputArgument; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class NodeSharedShowCommand extends BasePhpcrCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('node:shared:show'); 25 | $this->setDescription('Show all the nodes are in the shared set of this node'); 26 | $this->addArgument('path', InputArgument::REQUIRED, 'Path of node (can include wildcard)'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Lists all nodes that are in the shared set of this node. 30 | 31 | Shareable nodes are analagous to symbolic links in a linux filesystem and can 32 | be created by cloning a node within the same workspace. 33 | 34 | If this node is not shared then only this node is shown. 35 | HERE 36 | ); 37 | 38 | $this->requiresDescriptor(RepositoryInterface::OPTION_SHAREABLE_NODES_SUPPORTED, true); 39 | } 40 | 41 | public function execute(InputInterface $input, OutputInterface $output): int 42 | { 43 | $session = $this->get('phpcr.session'); 44 | $path = $input->getArgument('path'); 45 | $nodes = $session->findNodes($path); 46 | 47 | foreach ($nodes as $node) { 48 | $output->writeln(''.$node->getPath().''); 49 | $sharedSet = $node->getSharedSet(); 50 | 51 | foreach ($sharedSet as $sharedNode) { 52 | $output->writeln($sharedNode->getPath()); 53 | } 54 | } 55 | 56 | return 0; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeShowCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\NodeType\NoSuchNodeTypeException; 16 | use PHPCR\Util\CND\Writer\CndWriter; 17 | use Symfony\Component\Console\Input\InputArgument; 18 | use Symfony\Component\Console\Input\InputInterface; 19 | use Symfony\Component\Console\Output\OutputInterface; 20 | 21 | class NodeTypeShowCommand extends BasePhpcrCommand 22 | { 23 | protected function configure(): void 24 | { 25 | $this->setName('node-type:show'); 26 | $this->setDescription('Show the CND of a node type'); 27 | $this->addArgument('nodeTypeName', InputArgument::REQUIRED, 'The name of the node type to show'); 28 | $this->setHelp( 29 | <<<'HERE' 30 | Show the CND (Compact Node Definition) of a given node type. 31 | HERE 32 | ); 33 | } 34 | 35 | public function execute(InputInterface $input, OutputInterface $output): int 36 | { 37 | $session = $this->get('phpcr.session'); 38 | $nodeTypeName = $input->getArgument('nodeTypeName'); 39 | $workspace = $session->getWorkspace(); 40 | $namespaceRegistry = $workspace->getNamespaceRegistry(); 41 | $nodeTypeManager = $workspace->getNodeTypeManager(); 42 | 43 | try { 44 | $nodeType = $nodeTypeManager->getNodeType($nodeTypeName); 45 | } catch (NoSuchNodeTypeException $e) { 46 | throw new \Exception(sprintf( 47 | 'The node type "%s" does not exist', 48 | $nodeTypeName 49 | )); 50 | } 51 | $cndWriter = new CndWriter($namespaceRegistry); 52 | $out = $cndWriter->writeString([$nodeType]); 53 | $output->writeln(sprintf('%s', $out)); 54 | 55 | return 0; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeUnregisterCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class NodeTypeUnregisterCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('node-type:unregister'); 24 | $this->setDescription('Unregister a node type UNSUPPORTED / TODO'); 25 | $this->addArgument('nodeTypeName', InputArgument::REQUIRED, 'The name of the node type to unregister'); 26 | $this->setHelp( 27 | <<<'HERE' 28 | Unregisters the specified node type 29 | HERE 30 | ); 31 | 32 | $this->dequiresDescriptor('jackalope.not_implemented.node_type.unregister'); 33 | } 34 | 35 | public function execute(InputInterface $input, OutputInterface $output): int 36 | { 37 | $session = $this->get('phpcr.session'); 38 | $nodeTypeName = $input->getArgument('nodeTypeName'); 39 | $workspace = $session->getWorkspace(); 40 | $namespaceRegistry = $workspace->getNamespaceRegistry(); 41 | $nodeTypeManager = $workspace->getNodeTypeManager(); 42 | 43 | $nodeType = $nodeTypeManager->unregisterNodeTypes([$nodeTypeName]); 44 | 45 | return 0; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/QuerySelectCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputInterface; 16 | use Symfony\Component\Console\Output\OutputInterface; 17 | 18 | class QuerySelectCommand extends BaseQueryCommand 19 | { 20 | protected function configure(): void 21 | { 22 | $this->setName('select'); 23 | $this->setDescription('Execute a SELECT query (JCR-SQL2)'); 24 | $this->addArgument('query'); 25 | $this->setHelp( 26 | <<<'EOT' 27 | Execute a JCR-SQL2 query. Unlike other commands you can enter a query literally: 28 | 29 | SELECT * FROM [nt:unstructured]; 30 | 31 | This command only executes JCR-SQL2 queries at the moment. 32 | EOT 33 | ); 34 | } 35 | 36 | public function execute(InputInterface $input, OutputInterface $output): int 37 | { 38 | $sql = $this->getQuery($input); 39 | $input = $this->getQuery($input); 40 | 41 | $session = $this->get('phpcr.session'); 42 | $qm = $session->getWorkspace()->getQueryManager(); 43 | 44 | $query = $qm->createQuery($sql, 'JCR-SQL2'); 45 | 46 | $start = microtime(true); 47 | $result = $query->execute(); 48 | $elapsed = microtime(true) - $start; 49 | 50 | $this->get('helper.result_formatter')->formatQueryResult($result, $output, $elapsed); 51 | 52 | return 0; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldListCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\RepositoryInterface; 16 | use PHPCR\Shell\Console\Helper\Table; 17 | use Symfony\Component\Console\Input\InputArgument; 18 | use Symfony\Component\Console\Input\InputInterface; 19 | use Symfony\Component\Console\Output\OutputInterface; 20 | 21 | class RetentionHoldListCommand extends BasePhpcrCommand 22 | { 23 | protected function configure(): void 24 | { 25 | $this->setName('retention:hold:list'); 26 | $this->setDescription('List retention holds at given absolute path UNSUPPORTED'); 27 | $this->addArgument('absPath', InputArgument::REQUIRED, 'Absolute path to node to which we want to add a hold'); 28 | $this->setHelp( 29 | <<<'HERE' 30 | Lists all hold object names that have been added to the 31 | existing node at absPath. 32 | HERE 33 | ); 34 | 35 | $this->requiresDescriptor(RepositoryInterface::OPTION_RETENTION_SUPPORTED, true); 36 | } 37 | 38 | public function execute(InputInterface $input, OutputInterface $output): int 39 | { 40 | $session = $this->get('phpcr.session'); 41 | $retentionManager = $session->getRetentionManager(); 42 | $absPath = $input->getArgument('absPath'); 43 | 44 | $holds = $retentionManager->getHolds($absPath); 45 | $table = new Table($output); 46 | $table->setHeaders(['Name']); 47 | 48 | foreach ($holds as $hold) { 49 | $table->addRow([$hold->getName()]); 50 | } 51 | 52 | $table->render($output); 53 | 54 | return 0; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/RetentionPolicyGetCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\RepositoryInterface; 16 | use Symfony\Component\Console\Input\InputArgument; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class RetentionPolicyGetCommand extends BasePhpcrCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('retention:policy:get'); 25 | $this->setDescription('Get a retention policy for specified node UNSUPPORTED'); 26 | $this->addArgument('absPath', InputArgument::REQUIRED, 'Absolute path to node'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Gets the retention policy of a node identified by its path. 30 | HERE 31 | ); 32 | 33 | $this->requiresDescriptor(RepositoryInterface::OPTION_RETENTION_SUPPORTED, true); 34 | } 35 | 36 | public function execute(InputInterface $input, OutputInterface $output): int 37 | { 38 | $session = $this->get('phpcr.session'); 39 | $retentionManager = $session->getRetentionManager(); 40 | $absPath = $input->getArgument('absPath'); 41 | 42 | $policy = $retentionManager->getRetentionPolicy($absPath); 43 | if (!$policy) { 44 | $output->writeln('No retention policy'); 45 | } else { 46 | $output->writeln($policy->getName()); 47 | } 48 | 49 | return 0; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/RetentionPolicyRemoveCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\RepositoryInterface; 16 | use Symfony\Component\Console\Input\InputArgument; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class RetentionPolicyRemoveCommand extends BasePhpcrCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('retention:policy:remove'); 25 | $this->setDescription('Remove a retention policy for specified node UNSUPPORTED'); 26 | $this->addArgument('absPath', InputArgument::REQUIRED, 'Absolute path to node'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Removes the retention policy of a node identified by its path. 30 | HERE 31 | ); 32 | 33 | $this->requiresDescriptor(RepositoryInterface::OPTION_RETENTION_SUPPORTED, true); 34 | } 35 | 36 | public function execute(InputInterface $input, OutputInterface $output): int 37 | { 38 | $session = $this->get('phpcr.session'); 39 | $retentionManager = $session->getRetentionManager(); 40 | $absPath = $input->removeArgument('absPath'); 41 | 42 | $policy = $retentionManager->getRetentionPolicy($absPath); 43 | if (!$policy) { 44 | $output->writeln('No retention policy'); 45 | } else { 46 | $output->writeln($policy->remove()); 47 | } 48 | 49 | return 0; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/SessionImpersonateCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\SimpleCredentials; 16 | use Symfony\Component\Console\Input\InputArgument; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class SessionImpersonateCommand extends BasePhpcrCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('session:impersonate'); 25 | $this->setDescription('Impersonate the given user'); 26 | $this->addArgument('username', InputArgument::REQUIRED, 'Username of user to impersonate'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Note: This command is not implemented by any of the transports currently. 30 | 31 | Returns a new session in accordance with the specified (new) 32 | Credentials. 33 | HERE 34 | ); 35 | 36 | $this->dequiresDescriptor('jackalope.not_implemented.session.impersonate'); 37 | } 38 | 39 | public function execute(InputInterface $input, OutputInterface $output): int 40 | { 41 | $session = $this->get('phpcr.session'); 42 | $username = $input->getArgument('username'); 43 | 44 | $credentials = new SimpleCredentials($username, ''); 45 | $session->impersonate($credentials); 46 | 47 | return 0; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/SessionLoginCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class SessionLoginCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('session:login'); 24 | $this->setDescription('Login or (relogin) to a session'); 25 | $this->addArgument('userId', InputArgument::REQUIRED, 'Unique identifier of user'); 26 | $this->addArgument('password', InputArgument::REQUIRED, 'Password'); 27 | $this->addArgument('workspaceName', InputArgument::OPTIONAL, 'Optional workspace name'); 28 | $this->setHelp( 29 | <<<'HERE' 30 | Login to a session. 31 | HERE 32 | ); 33 | } 34 | 35 | public function execute(InputInterface $input, OutputInterface $output): int 36 | { 37 | $username = $input->getArgument('userId'); 38 | $password = $input->getArgument('password'); 39 | $workspaceName = $input->getArgument('workspaceName'); 40 | $this->get('phpcr.session_manager')->relogin($username, $password, $workspaceName); 41 | 42 | return 0; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/SessionLogoutCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputInterface; 16 | use Symfony\Component\Console\Output\OutputInterface; 17 | 18 | class SessionLogoutCommand extends BasePhpcrCommand 19 | { 20 | protected function configure(): void 21 | { 22 | $this->setName('session:logout'); 23 | $this->setDescription('Logout of the current session'); 24 | $this->setHelp( 25 | <<<'HERE' 26 | Releases all resources associated with this Session. 27 | 28 | This command should be called when a Session is no longer needed. 29 | HERE 30 | ); 31 | } 32 | 33 | public function execute(InputInterface $input, OutputInterface $output): int 34 | { 35 | $session = $this->get('phpcr.session'); 36 | $session->logout(); 37 | 38 | return 0; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceListCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\Shell\Console\Helper\Table; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class SessionNamespaceListCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('session:namespace:list'); 24 | $this->setDescription('List all namespace prefix to URI mappings in current session'); 25 | $this->setHelp( 26 | <<<'HERE' 27 | List all namespace prefix to URI mappings in current session 28 | HERE 29 | ); 30 | } 31 | 32 | public function execute(InputInterface $input, OutputInterface $output): int 33 | { 34 | $session = $this->get('phpcr.session'); 35 | $prefixes = $session->getNamespacePrefixes(); 36 | 37 | $table = new Table($output); 38 | $table->setHeaders(['Prefix', 'URI']); 39 | 40 | foreach ($prefixes as $prefix) { 41 | $uri = $session->getNamespaceURI($prefix); 42 | $table->addRow([$prefix, $uri]); 43 | } 44 | 45 | $table->render($output); 46 | 47 | return 0; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceSetCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class SessionNamespaceSetCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('session:namespace:set'); 24 | $this->setDescription('Set a namespace in the current session'); 25 | $this->addArgument('prefix', InputArgument::REQUIRED, 'The namespace prefix to be set as identifier'); 26 | $this->addArgument('uri', InputArgument::REQUIRED, 'The location of the namespace definition (usually a URI'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Sets the name of a namespace prefix. 30 | 31 | Within the scope of this Session, this method maps uri to prefix. The 32 | remapping only affects operations done through this Session. To clear 33 | all remappings, the client must acquire a new Session. 34 | All local mappings already present in the Session that include either 35 | the specified prefix or the specified uri are removed and the new 36 | mapping is added. 37 | HERE 38 | ); 39 | } 40 | 41 | public function execute(InputInterface $input, OutputInterface $output): int 42 | { 43 | $session = $this->get('phpcr.session'); 44 | $prefix = $input->getArgument('prefix'); 45 | $uri = $input->getArgument('uri'); 46 | 47 | $session->setNamespacePrefix($prefix, $uri); 48 | 49 | return 0; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/SessionRefreshCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputInterface; 16 | use Symfony\Component\Console\Input\InputOption; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class SessionRefreshCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('session:refresh'); 24 | $this->setDescription('Refresh the current session'); 25 | $this->addOption('keep-changes', null, InputOption::VALUE_NONE, 'Keep any changes that have been made in this session'); 26 | $this->setHelp( 27 | <<<'HERE' 28 | Reloads the current session. 29 | 30 | If the --keep-changes option is not given then this command discards 31 | all pending changes currently recorded in this Session and returns all items to 32 | reflect the current saved state. 33 | 34 | If keep-changes is true then pending change are not discarded but 35 | items that do not have changes pending have their state refreshed to reflect 36 | the current saved state, thus revealing changes made by other sessions. 37 | HERE 38 | ); 39 | } 40 | 41 | public function execute(InputInterface $input, OutputInterface $output): int 42 | { 43 | $session = $this->get('phpcr.session'); 44 | $keepChanges = $input->getOption('keep-changes'); 45 | 46 | $session->refresh($keepChanges); 47 | 48 | return 0; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/SessionSaveCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputInterface; 16 | use Symfony\Component\Console\Output\OutputInterface; 17 | 18 | class SessionSaveCommand extends BasePhpcrCommand 19 | { 20 | protected function configure(): void 21 | { 22 | $this->setName('session:save'); 23 | $this->setDescription('Save the current session'); 24 | $this->setHelp( 25 | <<<'HERE' 26 | Validates all pending changes currently recorded in this Session. 27 | 28 | If validation of all pending changes succeeds, then this change 29 | information is cleared from the Session. 30 | 31 | If the save occurs outside a transaction, the changes are dispatched and 32 | persisted. Upon being persisted the changes become potentially visible 33 | to other Sessions bound to the same persistent workspace. 34 | 35 | If the save occurs within a transaction, the changes are dispatched but 36 | are not persisted until the transaction is committed. 37 | 38 | If validation fails, then no pending changes are dispatched and they 39 | remain recorded on the Session. There is no best-effort or partial save. 40 | HERE 41 | ); 42 | } 43 | 44 | public function execute(InputInterface $input, OutputInterface $output): int 45 | { 46 | $session = $this->get('phpcr.session'); 47 | 48 | $session->save(); 49 | 50 | return 0; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckpointCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\RepositoryInterface; 16 | use Symfony\Component\Console\Input\InputArgument; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class VersionCheckpointCommand extends BasePhpcrCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('version:checkpoint'); 25 | $this->setDescription('Checkin and then checkout a node'); 26 | $this->addArgument('path', InputArgument::REQUIRED, 'Path to node'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Performs a version:checkin followed by a version:checkout on the versionable node at 30 | path 31 | 32 | If this node is already checked-in, this method is equivalent to version:checkout. 33 | HERE 34 | ); 35 | $this->requiresDescriptor(RepositoryInterface::OPTION_VERSIONING_SUPPORTED, true); 36 | } 37 | 38 | public function execute(InputInterface $input, OutputInterface $output): int 39 | { 40 | $session = $this->get('phpcr.session'); 41 | $nodeHelper = $this->get('helper.node'); 42 | $path = $input->getArgument('path'); 43 | $workspace = $session->getWorkspace(); 44 | 45 | $node = $session->getNodeByPathOrIdentifier($path); 46 | $nodeHelper->assertNodeIsVersionable($node); 47 | $versionManager = $workspace->getVersionManager(); 48 | $version = $versionManager->checkpoint($node->getPath()); 49 | 50 | $output->writeln('Version: '.$version->getName()); 51 | 52 | return 0; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceCreateCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class WorkspaceCreateCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('workspace:create'); 24 | $this->setDescription('Create a new workspace'); 25 | $this->addArgument('name', InputArgument::REQUIRED, 'Name of new workspace'); 26 | $this->addArgument('srcWorkspace', InputArgument::OPTIONAL, 'If specified, clone from this workspace'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Creates a new Workspace with the specified name. The new workspace is 30 | empty, meaning it contains only root node. 31 | 32 | If srcWorkspace is given, then it 33 | creates a new Workspace with the specified name initialized with a 34 | clone of the content of the workspace srcWorkspace. Semantically, 35 | this command is equivalent to creating a new workspace and manually 36 | cloning srcWorkspace to it. 37 | HERE 38 | ); 39 | } 40 | 41 | public function execute(InputInterface $input, OutputInterface $output): int 42 | { 43 | $session = $this->get('phpcr.session'); 44 | $name = $input->getArgument('name'); 45 | $srcWorkspace = $input->getArgument('srcWorkspace'); 46 | 47 | $workspace = $session->getWorkspace(); 48 | $workspace->createWorkspace($name, $srcWorkspace); 49 | 50 | return 0; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceDeleteCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class WorkspaceDeleteCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('workspace:delete'); 24 | $this->setDescription('Delete a workspace'); 25 | $this->addArgument('name', InputArgument::REQUIRED, 'Name of new workspace'); 26 | $this->addArgument('srcWorkspace', InputArgument::OPTIONAL, 'If specified, clone from this workspace'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Deletes the workspace with the specified name from the repository, 30 | deleting all content within it. 31 | HERE 32 | ); 33 | } 34 | 35 | public function execute(InputInterface $input, OutputInterface $output): int 36 | { 37 | $session = $this->get('phpcr.session'); 38 | $name = $input->getArgument('name'); 39 | 40 | $workspace = $session->getWorkspace(); 41 | $workspace->deleteWorkspace($name); 42 | 43 | return 0; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceListCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use PHPCR\Shell\Console\Helper\Table; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class WorkspaceNamespaceListCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('workspace:namespace:list'); 24 | $this->setDescription('List all namespace prefix to URI mappings in current workspace'); 25 | $this->setHelp( 26 | <<<'HERE' 27 | List all namespace prefix to URI mappings in current workspace 28 | HERE 29 | ); 30 | } 31 | 32 | public function execute(InputInterface $input, OutputInterface $output): int 33 | { 34 | $session = $this->get('phpcr.session'); 35 | $workspace = $session->getWorkspace(); 36 | $namespaceRegistry = $workspace->getNamespaceRegistry(); 37 | 38 | $prefixes = $namespaceRegistry->getPrefixes(); 39 | 40 | $table = new Table($output); 41 | $table->setHeaders(['Prefix', 'URI']); 42 | 43 | foreach ($prefixes as $prefix) { 44 | $uri = $namespaceRegistry->getURI($prefix); 45 | $table->addRow([$prefix, $uri]); 46 | } 47 | 48 | $table->render($output); 49 | 50 | return 0; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceRegisterCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class WorkspaceNamespaceRegisterCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('workspace:namespace:register'); 24 | $this->setDescription('Sets a one-to-one mapping between prefix and uri in the global namespace'); 25 | $this->addArgument('prefix', InputArgument::REQUIRED, 'The namespace prefix to be mapped'); 26 | $this->addArgument('uri', InputArgument::REQUIRED, 'The URI to be mapped'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | List all namespace prefix to URI mappings in current session 30 | HERE 31 | ); 32 | } 33 | 34 | public function execute(InputInterface $input, OutputInterface $output): int 35 | { 36 | $session = $this->get('phpcr.session'); 37 | $workspace = $session->getWorkspace(); 38 | $namespaceRegistry = $workspace->getNamespaceRegistry(); 39 | 40 | $prefix = $input->getArgument('prefix'); 41 | $uri = $input->getArgument('uri'); 42 | 43 | $namespaceRegistry->registerNamespace($prefix, $uri); 44 | 45 | return 0; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceUnregisterCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class WorkspaceNamespaceUnregisterCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('workspace:namespace:unregister'); 24 | $this->setDescription('Unregister a namespace'); 25 | $this->addArgument('uri', InputArgument::REQUIRED, 'The URI to be removed'); 26 | $this->setHelp( 27 | <<<'HERE' 28 | Removes the specified namespace URI from namespace registry. 29 | 30 | The following restrictions apply: 31 | 32 | - Attempting to unregister a built-in namespace (jcr, nt, mix, sv, xml or 33 | the empty namespace) will throw a NamespaceException. 34 | - An attempt to unregister a namespace that is not currently registered 35 | will throw a NamespaceException. 36 | - An implementation may prevent the unregistering of any other namespace 37 | for implementation-specific reasons by throwing a 38 | NamespaceException. 39 | HERE 40 | ); 41 | } 42 | 43 | public function execute(InputInterface $input, OutputInterface $output): int 44 | { 45 | $session = $this->get('phpcr.session'); 46 | $workspace = $session->getWorkspace(); 47 | $namespaceRegistry = $workspace->getNamespaceRegistry(); 48 | 49 | $uri = $input->getArgument('uri'); 50 | 51 | $namespaceRegistry->unregisterNamespaceByURI($uri); 52 | 53 | return 0; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceUseCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Phpcr; 14 | 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class WorkspaceUseCommand extends BasePhpcrCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('workspace:use'); 24 | $this->setDescription('Change the current workspace'); 25 | $this->addArgument('name', InputArgument::REQUIRED, 'Name of workspace to use'); 26 | $this->addArgument('srcWorkspace', InputArgument::OPTIONAL, 'If specified, clone from this workspace'); 27 | $this->setHelp( 28 | <<<'HERE' 29 | Change the workspace. 30 | HERE 31 | ); 32 | } 33 | 34 | public function execute(InputInterface $input, OutputInterface $output): int 35 | { 36 | $workspaceName = $input->getArgument('name'); 37 | $this->get('phpcr.session_manager')->changeWorkspace($workspaceName); 38 | 39 | return 0; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Shell/AliasListCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Shell; 14 | 15 | use PHPCR\Shell\Console\Command\BaseCommand; 16 | use PHPCR\Shell\Console\Helper\Table; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class AliasListCommand extends BaseCommand 21 | { 22 | public function configure(): void 23 | { 24 | $this->setName('shell:alias:list'); 25 | $this->setDescription('List all the registered aliases'); 26 | $this->setHelp( 27 | <<<'EOT' 28 | List the aliases as defined in ~/.phpcrsh/aliases.yml. 29 | EOT 30 | ); 31 | } 32 | 33 | public function execute(InputInterface $input, OutputInterface $output): int 34 | { 35 | $config = $this->get('config.manager'); 36 | $aliases = $config->getConfig('alias'); 37 | 38 | $table = new Table($output); 39 | $table->setHeaders(['Alias', 'Command']); 40 | 41 | foreach ($aliases as $alias => $command) { 42 | $table->addRow([$alias, $command]); 43 | } 44 | 45 | $table->render($output); 46 | 47 | return 0; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Shell/ClearCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Shell; 14 | 15 | use PHPCR\Shell\Console\Command\BaseCommand; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class ClearCommand extends BaseCommand 20 | { 21 | public function configure(): void 22 | { 23 | $this->setName('shell:clear'); 24 | $this->setDescription('Clear the screen'); 25 | $this->setHelp( 26 | <<<'EOT' 27 | Clear the screen 28 | EOT 29 | ); 30 | } 31 | 32 | public function execute(InputInterface $input, OutputInterface $output): int 33 | { 34 | $output->write("\033[2J\033[;H"); 35 | 36 | return 0; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Shell/ConfigInitCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Shell; 14 | 15 | use PHPCR\Shell\Console\Command\BaseCommand; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class ConfigInitCommand extends BaseCommand 20 | { 21 | protected $output; 22 | 23 | public function configure(): void 24 | { 25 | $this->setName('shell:config:init'); 26 | $this->setDescription('Initialize a local configuration with default values'); 27 | $this->setHelp( 28 | <<<'EOT' 29 | Initialize a new configuration folder, .phpcrsh in the users HOME directory. 30 | EOT 31 | ); 32 | } 33 | 34 | public function execute(InputInterface $input, OutputInterface $output): int 35 | { 36 | $this->output = $output; 37 | $configHelper = $this->get('config.manager'); 38 | $configHelper->initConfig($output); 39 | 40 | return 0; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Shell/ConfigReloadCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Shell; 14 | 15 | use PHPCR\Shell\Console\Command\BaseCommand; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class ConfigReloadCommand extends BaseCommand 20 | { 21 | protected $output; 22 | 23 | public function configure(): void 24 | { 25 | $this->setName('shell:config:reload'); 26 | $this->setDescription('Reload the configuration'); 27 | $this->setHelp( 28 | <<<'EOT' 29 | Reload the configuration 30 | EOT 31 | ); 32 | } 33 | 34 | public function execute(InputInterface $input, OutputInterface $output): int 35 | { 36 | $this->output = $output; 37 | $config = $this->get('config.manager'); 38 | $config->loadConfig(); 39 | 40 | return 0; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Shell/ExitCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Shell; 14 | 15 | use PHPCR\Shell\Console\Command\BaseCommand; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | use Symfony\Component\Console\Question\ConfirmationQuestion; 19 | 20 | class ExitCommand extends BaseCommand 21 | { 22 | public function configure(): void 23 | { 24 | $this->setName('shell:exit'); 25 | $this->setDescription('Logout and quit the shell'); 26 | } 27 | 28 | public function execute(InputInterface $input, OutputInterface $output): int 29 | { 30 | $dialog = $this->get('helper.question'); 31 | $session = $this->get('phpcr.session'); 32 | 33 | if ($session->hasPendingChanges()) { 34 | $res = false; 35 | 36 | if ($input->isInteractive()) { 37 | $res = $dialog->ask($input, $output, new ConfirmationQuestion('Session has pending changes, are you sure you want to quit? (Y/N)', false)); 38 | } 39 | 40 | if (false === $res) { 41 | return 0; 42 | } 43 | } 44 | 45 | $session->logout(); 46 | $output->writeln('Bye!'); 47 | exit(0); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Shell/PathChangeCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Shell; 14 | 15 | use PHPCR\PathNotFoundException; 16 | use PHPCR\Shell\Console\Command\BaseCommand; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class PathChangeCommand extends BaseCommand 21 | { 22 | protected function configure(): void 23 | { 24 | $this->setName('shell:path:change'); 25 | $this->setDescription('Change the current path'); 26 | $this->addArgument('path'); 27 | } 28 | 29 | public function execute(InputInterface $input, OutputInterface $output): int 30 | { 31 | $session = $this->get('phpcr.session'); 32 | $path = $input->getArgument('path'); 33 | 34 | try { 35 | $session->chdir($path); 36 | $output->writeln(''.$session->getCwd().''); 37 | } catch (PathNotFoundException $e) { 38 | $output->writeln(''.$e->getMessage().''); 39 | } 40 | 41 | return 0; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Shell/PathShowCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Shell; 14 | 15 | use PHPCR\Shell\Console\Command\BaseCommand; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | class PathShowCommand extends BaseCommand 20 | { 21 | protected function configure(): void 22 | { 23 | $this->setName('shell:path:show'); 24 | $this->setDescription('Print Working Directory (or path)'); 25 | } 26 | 27 | public function execute(InputInterface $input, OutputInterface $output): int 28 | { 29 | $output->writeln( 30 | ''.$this->get('phpcr.session')->getCwd().'' 31 | ); 32 | 33 | return 0; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Command/Shell/ProfileShowCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Command\Shell; 14 | 15 | use PHPCR\Shell\Console\Command\BaseCommand; 16 | use PHPCR\Shell\Console\Helper\Table; 17 | use Symfony\Component\Console\Input\InputInterface; 18 | use Symfony\Component\Console\Output\OutputInterface; 19 | 20 | class ProfileShowCommand extends BaseCommand 21 | { 22 | protected $output; 23 | 24 | public function configure(): void 25 | { 26 | $this->setName('shell:profile:show'); 27 | $this->setDescription('Show the current profile configuration'); 28 | $this->setHelp( 29 | <<<'EOT' 30 | Display the currently loaded profile configuration 31 | EOT 32 | ); 33 | } 34 | 35 | public function execute(InputInterface $input, OutputInterface $output): int 36 | { 37 | $this->output = $output; 38 | $profile = $this->get('config.profile'); 39 | 40 | $output->writeln('NOTE: The profile may include information not relating to your current transport'); 41 | $output->writeln(''); 42 | foreach ($profile->toArray() as $domain => $config) { 43 | $output->writeln(''.$domain.''); 44 | $table = new Table($output); 45 | $table->setHeaders(['Key', 'Value']); 46 | 47 | foreach ($config as $key => $value) { 48 | if ($key === 'db_password') { 49 | $value = '***'; 50 | } 51 | 52 | $table->addRow([ 53 | $key, 54 | is_scalar($value) ? $value : json_encode($value), 55 | ]); 56 | } 57 | $table->render($output); 58 | } 59 | 60 | return 0; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Helper/NodeHelper.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Helper; 14 | 15 | use PHPCR\NodeInterface; 16 | use Symfony\Component\Console\Helper\Helper; 17 | 18 | /** 19 | * Helper for nodes. 20 | * 21 | * @author Daniel Leech 22 | */ 23 | class NodeHelper extends Helper 24 | { 25 | /** 26 | * Return true if the given node has the given mixinType. 27 | * 28 | * @return bool 29 | */ 30 | public function nodeHasMixinType($node, $mixinTypeName) 31 | { 32 | return $node->isNodeType($mixinTypeName); 33 | } 34 | 35 | /** 36 | * Return true if the given node is versionable. 37 | */ 38 | public function assertNodeIsVersionable(NodeInterface $node) 39 | { 40 | if (!$this->nodeHasMixinType($node, 'mix:versionable')) { 41 | throw new \OutOfBoundsException(sprintf( 42 | 'Node "%s" is not versionable', 43 | $node->getPath() 44 | )); 45 | } 46 | } 47 | 48 | public function getName(): string 49 | { 50 | return 'node'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Helper/PathHelper.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Helper; 14 | 15 | use PHPCR\Util\PathHelper as StaticPathHelper; 16 | use Symfony\Component\Console\Helper\Helper; 17 | 18 | /** 19 | * Phpcr path helper. 20 | * 21 | * @author Daniel Leech 22 | */ 23 | class PathHelper extends Helper 24 | { 25 | /** 26 | * @see StaticPathHelper::getParentPath 27 | */ 28 | public function getParentPath($path) 29 | { 30 | return StaticPathHelper::getParentPath($path); 31 | } 32 | 33 | /** 34 | * @see StaticPathHelper::getNodeName 35 | */ 36 | public function getNodeName($path) 37 | { 38 | return StaticPathHelper::getNodeName($path); 39 | } 40 | 41 | public function getName(): string 42 | { 43 | return 'path'; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Helper/Table.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Helper; 14 | 15 | use Symfony\Component\Console\Helper\Table as OriginalTable; 16 | 17 | class Table extends OriginalTable 18 | { 19 | private $nbRows = 0; 20 | 21 | public function addRow($row): static 22 | { 23 | $this->nbRows++; 24 | 25 | return parent::addRow($row); 26 | } 27 | 28 | public function getNumberOfRows() 29 | { 30 | return $this->nbRows; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Console/Input/AutoComplete.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Input; 14 | 15 | use PHPCR\Shell\Console\Application\ShellApplication; 16 | use PHPCR\Shell\Phpcr\PhpcrSession; 17 | 18 | /** 19 | * Class for autocompleting commands. 20 | * 21 | * @author Daniel Leech 22 | */ 23 | class AutoComplete 24 | { 25 | private $application; 26 | private $session; 27 | 28 | public function __construct(ShellApplication $application, PhpcrSession $session) 29 | { 30 | $this->application = $application; 31 | $this->session = $session; 32 | } 33 | 34 | public function autocomplete($text) 35 | { 36 | $list = array_keys($this->application->all()); 37 | 38 | $node = $this->session->getCurrentNode(); 39 | 40 | foreach ($node->getNodes() as $node) { 41 | $list[] = $node->getName(); 42 | } 43 | 44 | foreach ($node->getProperties() as $property) { 45 | $list[] = $property->getName(); 46 | } 47 | 48 | return $list; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/DependencyInjection/ContainerAwareInterface.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace PHPCR\Shell\DependencyInjection; 13 | 14 | use Symfony\Component\DependencyInjection\ContainerInterface; 15 | 16 | /** 17 | * This was removed from Symfony in version 7. 18 | * 19 | * We keep using the pattern in the shell commands for now to avoid a complicated refactor. 20 | * 21 | * @author Fabien Potencier 22 | */ 23 | interface ContainerAwareInterface 24 | { 25 | public function setContainer(?ContainerInterface $container): void; 26 | } 27 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Event/ApplicationInitEvent.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Event; 14 | 15 | use Symfony\Component\Console\Application; 16 | 17 | /** 18 | * This event is fired when the main shell application 19 | * is initialized. 20 | * 21 | * @author Daniel Leech 22 | */ 23 | class ApplicationInitEvent extends Event 24 | { 25 | protected $application; 26 | 27 | public function __construct(Application $application) 28 | { 29 | $this->application = $application; 30 | } 31 | 32 | public function getApplication() 33 | { 34 | return $this->application; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Event/CommandExceptionEvent.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Event; 14 | 15 | use PHPCR\Shell\Console\Application\ShellApplication; 16 | use Symfony\Component\Console\Output\OutputInterface; 17 | 18 | class CommandExceptionEvent extends Event 19 | { 20 | protected $exception; 21 | protected $output; 22 | protected $application; 23 | 24 | public function __construct(\Exception $exception, ShellApplication $application, OutputInterface $output) 25 | { 26 | $this->exception = $exception; 27 | $this->output = $output; 28 | $this->application = $application; 29 | } 30 | 31 | public function getException() 32 | { 33 | return $this->exception; 34 | } 35 | 36 | public function getOutput() 37 | { 38 | return $this->output; 39 | } 40 | 41 | public function getApplication() 42 | { 43 | return $this->application; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Event/CommandPreRunEvent.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Event; 14 | 15 | use Symfony\Component\Console\Input\InputInterface; 16 | 17 | class CommandPreRunEvent extends Event 18 | { 19 | protected $commandName; 20 | protected $input; 21 | 22 | public function __construct($commandName, InputInterface $input) 23 | { 24 | $this->commandName = $commandName; 25 | $this->input = $input; 26 | } 27 | 28 | public function getInput() 29 | { 30 | return $this->input; 31 | } 32 | 33 | public function setInput($input) 34 | { 35 | $this->input = $input; 36 | } 37 | 38 | public function getCommandName() 39 | { 40 | return $this->commandName; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Event/Event.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Event; 14 | 15 | /** 16 | * Events for Phpcr Shell. 17 | * 18 | * @author Daniel Leech 19 | */ 20 | class PhpcrShellEvents 21 | { 22 | /** 23 | * Fired when an exception is thrown. 24 | */ 25 | const COMMAND_EXCEPTION = 'command.exception'; 26 | 27 | /** 28 | * Fired before a command is executed. 29 | */ 30 | const COMMAND_PRE_RUN = 'command.pre_run'; 31 | 32 | /** 33 | * Fired when the application is initialized. 34 | */ 35 | const APPLICATION_INIT = 'application.init'; 36 | 37 | /** 38 | * Fired when the profile needs to be populated. 39 | */ 40 | const PROFILE_INIT = 'profile.init'; 41 | } 42 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Event/ProfileInitEvent.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Event; 14 | 15 | use PHPCR\Shell\Config\Profile; 16 | use Symfony\Component\Console\Input\InputInterface; 17 | use Symfony\Component\Console\Output\OutputInterface; 18 | 19 | /** 20 | * Event that is fired when the Profile needs to be initialized. 21 | * 22 | * The profile is always created as a new object, event listeners 23 | * then populate it. (e.g. from a config file, or from CLI params) 24 | * 25 | * @author Daniel Leech 26 | */ 27 | class ProfileInitEvent extends Event 28 | { 29 | protected $profile; 30 | protected $input; 31 | protected $output; 32 | 33 | public function __construct(Profile $profile, InputInterface $input, OutputInterface $output) 34 | { 35 | $this->profile = $profile; 36 | $this->input = $input; 37 | $this->output = $output; 38 | } 39 | 40 | public function getInput() 41 | { 42 | return $this->input; 43 | } 44 | 45 | public function getOutput() 46 | { 47 | return $this->output; 48 | } 49 | 50 | public function getProfile() 51 | { 52 | return $this->profile; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Query/ColumnOperand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Query; 14 | 15 | /** 16 | * Simple class to represent column operands in query 17 | * evaluations. 18 | * 19 | * @author Daniel Leech 20 | */ 21 | class ColumnOperand 22 | { 23 | private $selectorName; 24 | private $propertyName; 25 | 26 | public function __construct($selectorName, $propertyName) 27 | { 28 | $this->selectorName = $selectorName; 29 | $this->propertyName = $propertyName; 30 | } 31 | 32 | public function getSelectorName() 33 | { 34 | return $this->selectorName; 35 | } 36 | 37 | public function getPropertyName() 38 | { 39 | return $this->propertyName; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Query/Validator.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Query; 14 | 15 | class Validator 16 | { 17 | /** 18 | * Assert that queries are terminated with ";". 19 | * 20 | * @param string $sql2 21 | */ 22 | public static function validateQuery($sql2) 23 | { 24 | if (!str_ends_with($sql2, ';')) { 25 | throw new \InvalidArgumentException( 26 | 'Queries must be terminated with ";"' 27 | ); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Resources/config.dist/alias.yml: -------------------------------------------------------------------------------- 1 | # Shell shortcuts 2 | aliases: shell:alias:list 3 | creload: shell:config:reload 4 | cinit: shell:config:init 5 | clear: shell:clear 6 | 7 | # MySQL commands 8 | use: workspace:use 9 | explain: node-type:show 10 | 11 | # Filesystem commands 12 | cd: shell:path:change 13 | rm: node:remove 14 | mv: node:move 15 | pwd: shell:path:show 16 | exit: shell:exit 17 | 18 | # Node commands 19 | ls: node:list 20 | ln: node:clone # symlink, as in ln -s 21 | cp: node:copy 22 | cat: node:property:show 23 | touch: node:property:set 24 | mkdir: node:create 25 | 26 | # Node type commands 27 | mixins: node-type:list "^mix:" 28 | nodetypes: node-type:list 29 | ntedit: node-type:edit 30 | ntshow: node-type:show 31 | 32 | # Workspace commands 33 | workspaces: workspace:list 34 | 35 | # Namespsce commands 36 | namespaces: workspace:namespace:list 37 | nsset: workspace:namespace:register 38 | 39 | # Editor commands 40 | vi: node:edit 41 | vim: node:edit 42 | nano: node:edit 43 | 44 | # GNU commands 45 | man: help 46 | 47 | # Version commands 48 | checkin: version:checkin 49 | ci: version:checkin 50 | co: version:checkout 51 | checkout: version:checkout 52 | checkpoint: version:checkpoint 53 | vhist: version:history 54 | versions: version:history 55 | 56 | # Session commands 57 | save: session:save 58 | s: session:save 59 | refresh: session:refresh 60 | r: session:refresh 61 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Resources/config.dist/phpcrsh.yml: -------------------------------------------------------------------------------- 1 | # PHPCRSH configuration 2 | # 3 | # This is a copy of the default configuration 4 | # 5 | # You may delete any or all of the keys as it will be merged 6 | # on top of the default configuration. 7 | # 8 | 9 | # Amount of decimal expansion when showing timing information 10 | execution_time_expansion: 6 11 | 12 | # Show execution time for queries 13 | show_execution_time_query: true 14 | 15 | # Show execution time for node list operations (i.e. node:list) 16 | show_execution_time_list: true 17 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Serializer/YamlEncoder.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Serializer; 14 | 15 | use Symfony\Component\Serializer\Encoder\DecoderInterface; 16 | use Symfony\Component\Serializer\Encoder\EncoderInterface; 17 | use Symfony\Component\Yaml\Yaml; 18 | 19 | /** 20 | * Encodes YAML data. 21 | * 22 | * @author Daniel Leech 23 | */ 24 | class YamlEncoder implements EncoderInterface, DecoderInterface 25 | { 26 | /** 27 | * Encodes PHP data to a YAML string. 28 | * 29 | * {@inheritdoc} 30 | */ 31 | public function encode($data, $format, array $context = []): string 32 | { 33 | return Yaml::dump($data); 34 | } 35 | 36 | public function decode($data, $format, array $context = []): mixed 37 | { 38 | $arr = Yaml::parse($data); 39 | 40 | return $arr; 41 | } 42 | 43 | /** 44 | * {@inheritdoc} 45 | */ 46 | public function supportsEncoding($format): bool 47 | { 48 | return 'yaml' === $format; 49 | } 50 | 51 | /** 52 | * {@inheritdoc} 53 | */ 54 | public function supportsDecoding($format): bool 55 | { 56 | return 'yaml' === $format; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Subscriber/AutoSaveSubscriber.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Subscriber; 14 | 15 | use Symfony\Component\Console\ConsoleEvents; 16 | use Symfony\Component\Console\Event\ConsoleTerminateEvent; 17 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; 18 | 19 | /** 20 | * Automatically save on console terminate event. 21 | * 22 | * @author Daniel Leech 23 | */ 24 | class AutoSaveSubscriber implements EventSubscriberInterface 25 | { 26 | public static function getSubscribedEvents() 27 | { 28 | return [ 29 | ConsoleEvents::TERMINATE => 'handleTerminate', 30 | ]; 31 | } 32 | 33 | public function handleTerminate(ConsoleTerminateEvent $event) 34 | { 35 | $command = $event->getCommand(); 36 | if (!$command) { 37 | return; 38 | } 39 | $output = $event->getOutput(); 40 | $session = $command->get('phpcr.session'); 41 | if (!$session) { 42 | throw new \InvalidArgumentException('expected phpcr.session to exist'); 43 | } 44 | 45 | if ($session->hasPendingChanges()) { 46 | $output->writeln('Auto-saving session'); 47 | } 48 | $session->save(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Subscriber/ConfigInitSubscriber.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Subscriber; 14 | 15 | use PHPCR\Shell\Config\ConfigManager; 16 | use PHPCR\Shell\Event\ApplicationInitEvent; 17 | use PHPCR\Shell\Event\PhpcrShellEvents; 18 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; 19 | 20 | /** 21 | * Subscriber to initialize the configuration if it does not 22 | * already exist upon application initialization. 23 | * 24 | * @author Daniel Leech 25 | */ 26 | class ConfigInitSubscriber implements EventSubscriberInterface 27 | { 28 | private $configManager; 29 | 30 | public function __construct(ConfigManager $configManager) 31 | { 32 | $this->configManager = $configManager; 33 | } 34 | 35 | public static function getSubscribedEvents() 36 | { 37 | return [ 38 | PhpcrShellEvents::APPLICATION_INIT => 'handleApplicationInit', 39 | ]; 40 | } 41 | 42 | public function handleApplicationInit(ApplicationInitEvent $event) 43 | { 44 | $configDir = $this->configManager->getConfigDir(); 45 | 46 | if (!file_exists($configDir)) { 47 | $this->configManager->initConfig(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Subscriber/ExceptionSubscriber.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Subscriber; 14 | 15 | use Jackalope\NotImplementedException; 16 | use PHPCR\Shell\Event\CommandExceptionEvent; 17 | use PHPCR\Shell\Event\PhpcrShellEvents; 18 | use PHPCR\UnsupportedRepositoryOperationException; 19 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; 20 | 21 | /** 22 | * Try and better handle exceptions. 23 | * 24 | * @author Daniel Leech 25 | */ 26 | class ExceptionSubscriber implements EventSubscriberInterface 27 | { 28 | public static function getSubscribedEvents() 29 | { 30 | return [ 31 | PhpcrShellEvents::COMMAND_EXCEPTION => 'handleException', 32 | ]; 33 | } 34 | 35 | public function handleException(CommandExceptionEvent $event) 36 | { 37 | $exception = $event->getException(); 38 | $output = $event->getOutput(); 39 | $application = $event->getApplication(); 40 | 41 | if ($exception instanceof UnsupportedRepositoryOperationException) { 42 | $output->writeln('Unsupported repository operation: This repository is not capable of performing the requested action'); 43 | } 44 | 45 | if ($exception instanceof NotImplementedException) { 46 | $output->writeln('Not implemented: '.$exception->getMessage().''); 47 | } 48 | 49 | $output->writeln('['.get_class($exception).'] '.$exception->getMessage().''); 50 | 51 | if ($application->isDebug()) { 52 | $output->writeln(''.$exception->getTraceAsString().''); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Test/EmbeddedContext.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Test; 14 | 15 | use PHPCR\Shell\DependencyInjection\Container; 16 | use PHPCR\Shell\Phpcr\PhpcrSession; 17 | use PHPCR\Shell\PhpcrShell; 18 | 19 | /** 20 | * Features context. 21 | * 22 | * Start the shell in the embedded context 23 | */ 24 | class EmbeddedContext extends ContextBase 25 | { 26 | protected function createTester() 27 | { 28 | // embbed a new session 29 | $session = $this->getSession(null, true); 30 | $container = new Container(PhpcrShell::MODE_EMBEDDED_SHELL); 31 | $container->get('phpcr.session_manager')->setSession(new PhpcrSession($session)); 32 | $application = $container->get('application'); 33 | $application->setShowUnsupported(true); 34 | $tester = new ApplicationTester($application); 35 | 36 | return $tester; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Test/StandaloneContext.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Test; 14 | 15 | use PHPCR\Shell\Console\Application\SessionApplication; 16 | 17 | /** 18 | * Features context. 19 | */ 20 | class StandaloneContext extends ContextBase 21 | { 22 | protected function createTester() 23 | { 24 | $sessionApplication = new SessionApplication(); 25 | $shellApplication = $sessionApplication->getShellApplication(); 26 | $tester = new ApplicationTester($sessionApplication, $shellApplication); 27 | $tester->run([ 28 | '--transport' => 'jackrabbit', 29 | '--no-interaction' => true, 30 | '--unsupported' => true, // test all the commands, even if they are unsupported (we test for the fail) 31 | ], [ 32 | 'interactive' => true, 33 | ]); 34 | 35 | return $tester; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Transport/Transport/DoctrineDbal.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Transport\Transport; 14 | 15 | use Doctrine\DBAL\DriverManager; 16 | use Jackalope\RepositoryFactoryDoctrineDBAL; 17 | use PHPCR\Shell\Config\Config; 18 | use PHPCR\Shell\Transport\TransportInterface; 19 | 20 | class DoctrineDbal implements TransportInterface 21 | { 22 | public function getName() 23 | { 24 | return 'doctrine-dbal'; 25 | } 26 | 27 | public function getRepository(Config $config) 28 | { 29 | $connection = DriverManager::getConnection([ 30 | 'user' => $config['db_username'], 31 | 'password' => $config['db_password'], 32 | 'host' => $config['db_host'], 33 | 'driver' => $config['db_driver'], 34 | 'dbname' => $config['db_name'], 35 | 'path' => $config['db_path'], 36 | ]); 37 | 38 | $factory = new RepositoryFactoryDoctrineDBAL(); 39 | $repository = $factory->getRepository([ 40 | 'jackalope.doctrine_dbal_connection' => $connection, 41 | ]); 42 | 43 | return $repository; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Transport/Transport/JackalopeFs.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Transport\Transport; 14 | 15 | use Jackalope\RepositoryFactoryFilesystem; 16 | use PHPCR\Shell\Config\Config; 17 | use PHPCR\Shell\Transport\TransportInterface; 18 | 19 | class JackalopeFs implements TransportInterface 20 | { 21 | public function getName() 22 | { 23 | return 'jackalope-fs'; 24 | } 25 | 26 | public function getRepository(Config $config) 27 | { 28 | $params = [ 29 | 'path' => $config['repo_path'], 30 | ]; 31 | $factory = new RepositoryFactoryFilesystem(); 32 | 33 | return $factory->getRepository($params); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Transport/Transport/Jackrabbit.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Transport\Transport; 14 | 15 | use Jackalope\RepositoryFactoryJackrabbit; 16 | use PHPCR\Shell\Config\Config; 17 | use PHPCR\Shell\Transport\TransportInterface; 18 | 19 | class Jackrabbit implements TransportInterface 20 | { 21 | public function getName() 22 | { 23 | return 'jackrabbit'; 24 | } 25 | 26 | public function getRepository(Config $config) 27 | { 28 | $params = [ 29 | 'jackalope.jackrabbit_uri' => $config['repo_url'], 30 | ]; 31 | $factory = new RepositoryFactoryJackrabbit(); 32 | 33 | return $factory->getRepository($params); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Transport/TransportInterface.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Transport; 14 | 15 | use PHPCR\Shell\Config\Config; 16 | 17 | /** 18 | * All phpcr-shell transports must implement this interface. 19 | * 20 | * @author Daniel Leech 21 | */ 22 | interface TransportInterface 23 | { 24 | public function getName(); 25 | 26 | public function getRepository(Config $config); 27 | } 28 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Transport/TransportRegistry.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Transport; 14 | 15 | class TransportRegistry implements TransportRegistryInterface 16 | { 17 | protected $transports = []; 18 | 19 | public function register(TransportInterface $transport) 20 | { 21 | $this->transports[$transport->getname()] = $transport; 22 | } 23 | 24 | public function getTransportNames() 25 | { 26 | return array_keys($this->transports); 27 | } 28 | 29 | public function getTransport($name) 30 | { 31 | return $this->transports[$name]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/PHPCR/Shell/Transport/TransportRegistryInterface.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Transport; 14 | 15 | /** 16 | * Interface for transport factory. 17 | * 18 | * Note that transport registry is a bit of a misnomer - 19 | * logically it would be RepositoryFactoryInitializerInterface, 20 | * which is too long imo. 21 | * 22 | * @author Daniel Leech 23 | */ 24 | interface TransportRegistryInterface 25 | { 26 | /** 27 | * Return all of the registered transport names. 28 | * 29 | * @return array 30 | */ 31 | public function getTransportNames(); 32 | 33 | /** 34 | * Return the transport with the given name. 35 | * 36 | * @param string $name 37 | * 38 | * @return TransportInterface 39 | */ 40 | public function getTransport($name); 41 | } 42 | -------------------------------------------------------------------------------- /tests/PHPCR/Shell/Helper/EditorHelperTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Helper; 14 | 15 | use PHPUnit\Framework\TestCase; 16 | 17 | class EditorHelperTest extends TestCase 18 | { 19 | protected $helper; 20 | 21 | public function setUp(): void 22 | { 23 | $this->helper = new EditorHelper(); 24 | putenv('EDITOR=cat'); 25 | } 26 | 27 | public function testFromValue() 28 | { 29 | $res = $this->helper->fromString( 30 | <<<'EOT' 31 | One 32 | Two 33 | Three 34 | EOT 35 | ); 36 | 37 | $this->assertEquals( 38 | <<<'EOT' 39 | One 40 | Two 41 | Three 42 | EOT 43 | , 44 | $res 45 | ); 46 | } 47 | 48 | public function testFromValueNoEditor() 49 | { 50 | $this->expectException(\RuntimeException::class); 51 | 52 | putenv('EDITOR='); 53 | $res = $this->helper->fromString('asd'); 54 | } 55 | 56 | public function provideFromStringWithMessage() 57 | { 58 | return [ 59 | [ 60 | <<<'EOT' 61 | This is some text that I want to edit 62 | EOT 63 | , 64 | <<<'EOT' 65 | This is some text that I want the user to see in a commend 66 | 67 | OK 68 | EOT 69 | ], 70 | ]; 71 | } 72 | 73 | /** 74 | * @dataProvider provideFromStringWithMessage 75 | */ 76 | public function testFromStringWithMessage($source, $message) 77 | { 78 | $res = $this->helper->fromStringWithMessage($source, $message); 79 | $this->assertSame($source, $res); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /tests/PHPCR/Shell/Helper/NodeHelperTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | * 11 | */ 12 | 13 | namespace PHPCR\Shell\Console\Helper; 14 | 15 | use PHPCR\NodeInterface; 16 | use PHPUnit\Framework\TestCase; 17 | use Prophecy\PhpUnit\ProphecyTrait; 18 | 19 | class NodeHelperTest extends TestCase 20 | { 21 | use ProphecyTrait; 22 | 23 | protected $nodeHelper; 24 | 25 | public function setUp(): void 26 | { 27 | $this->session = $this->prophesize('PHPCR\SessionInterface'); 28 | $this->helper = new NodeHelper($this->session->reveal()); 29 | $this->node = $this->prophesize(NodeInterface::class); 30 | 31 | $this->nodeType1 = $this->prophesize('PHPCR\NodeType\NodeTypeInterface'); 32 | } 33 | 34 | public function provideAssertNodeIsVersionable() 35 | { 36 | return [ 37 | [true], 38 | [false], 39 | ]; 40 | } 41 | 42 | /** 43 | * @dataProvider provideAssertNodeIsVersionable 44 | */ 45 | public function testAssertNodeIsVersionable($isVersionable) 46 | { 47 | $this->node->getPath()->willReturn('/'); 48 | $this->node->isNodeType('mix:versionable')->willReturn($isVersionable)->shouldBeCalled(); 49 | 50 | if (false == $isVersionable) { 51 | $this->expectException('\OutOfBoundsException', 'is not versionable'); 52 | } 53 | $this->helper->assertNodeIsVersionable($this->node->reveal()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /tests/bin/travis_jackrabbit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_NAME="${0##*/}" 4 | SCRIPT_DIR="${0%/*}" 5 | 6 | # if the script was started from the base directory, then the 7 | # expansion returns a period 8 | if test "$SCRIPT_DIR" == "." ; then 9 | SCRIPT_DIR="$PWD" 10 | # if the script was not called with an absolute path, then we need to add the 11 | # current working directory to the relative path of the script 12 | elif test "${SCRIPT_DIR:0:1}" != "/" ; then 13 | SCRIPT_DIR="$PWD/$SCRIPT_DIR" 14 | fi 15 | 16 | ./vendor/jackalope/jackalope-jackrabbit/bin/jackrabbit.sh 17 | --------------------------------------------------------------------------------