diff --git a/.travis.yml b/.travis.yml index 80a2e082..863e121b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,18 @@ language: php +env: + - BEHAT_SUITE=standalone + - BEHAT_SUITE=embedded + + php: - 5.4 before_script: - - composer install + - composer install --dev - bash tests/bin/travis_jackrabbit.sh script: - phpunit - - php vendor/behat/behat/bin/behat - php vendor/bin/phpspec run + - php vendor/behat/behat/bin/behat --suite=$BEHAT_SUITE diff --git a/CHANGELOG.md b/CHANGELOG.md index 41ff04cf..a4efcc61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Changelog dev-master ---------- +- [global] Refactored to use DI container and various general improvements - [node:references] Shows the referencing node paths instead of the referrered-to node path(s) alpha-6 diff --git a/behat.yml b/behat.yml new file mode 100644 index 00000000..fcff41d1 --- /dev/null +++ b/behat.yml @@ -0,0 +1,16 @@ +default: + suites: + standalone: + contexts: + - PHPCR\Shell\Test\StandaloneContext + paths: + - features/all + - features/standalone + - features/shell + embedded: + filter: + tag: "~@standalone" + contexts: + - PHPCR\Shell\Test\EmbeddedContext + paths: + - features/all diff --git a/composer.json b/composer.json index f1635ca1..c6506530 100644 --- a/composer.json +++ b/composer.json @@ -8,14 +8,16 @@ "phpcr/phpcr-utils": "~1.2", "symfony/finder": "~2.3", "symfony/serializer": "~2.3", - "symfony/yaml": "~2.3" + "symfony/yaml": "~2.3", + "symfony/dependency-injection": "~2.3" }, "minimum-stability": "dev", "require-dev": { + "symfony/symfony": "2.6", "symfony/process": "~2.3", "symfony/filesystem": "~2.3", "phpunit/phpunit": "~3.7.28", - "behat/behat": "~2.5", + "behat/behat": "~3.0.0", "phpspec/phpspec": "2.0", "jackalope/jackalope-doctrine-dbal": "~1.1", "jackalope/jackalope-jackrabbit": "~1.1" diff --git a/features/phpcr_access_control_privilege_list.feature b/features/all/phpcr_access_control_privilege_list.feature similarity index 100% rename from features/phpcr_access_control_privilege_list.feature rename to features/all/phpcr_access_control_privilege_list.feature diff --git a/features/phpcr_file_import.feature b/features/all/phpcr_file_import.feature similarity index 100% rename from features/phpcr_file_import.feature rename to features/all/phpcr_file_import.feature diff --git a/features/phpcr_lock_info.feature b/features/all/phpcr_lock_info.feature similarity index 100% rename from features/phpcr_lock_info.feature rename to features/all/phpcr_lock_info.feature diff --git a/features/phpcr_lock_lock.feature b/features/all/phpcr_lock_lock.feature similarity index 100% rename from features/phpcr_lock_lock.feature rename to features/all/phpcr_lock_lock.feature diff --git a/features/phpcr_lock_refresh.feature b/features/all/phpcr_lock_refresh.feature similarity index 100% rename from features/phpcr_lock_refresh.feature rename to features/all/phpcr_lock_refresh.feature diff --git a/features/phpcr_lock_token_add.feature b/features/all/phpcr_lock_token_add.feature similarity index 100% rename from features/phpcr_lock_token_add.feature rename to features/all/phpcr_lock_token_add.feature diff --git a/features/phpcr_lock_token_list.feature b/features/all/phpcr_lock_token_list.feature similarity index 100% rename from features/phpcr_lock_token_list.feature rename to features/all/phpcr_lock_token_list.feature diff --git a/features/phpcr_lock_token_remove.feature b/features/all/phpcr_lock_token_remove.feature similarity index 100% rename from features/phpcr_lock_token_remove.feature rename to features/all/phpcr_lock_token_remove.feature diff --git a/features/phpcr_lock_unlock.feature b/features/all/phpcr_lock_unlock.feature similarity index 100% rename from features/phpcr_lock_unlock.feature rename to features/all/phpcr_lock_unlock.feature diff --git a/features/phpcr_namespace_unregister.feature b/features/all/phpcr_namespace_unregister.feature similarity index 100% rename from features/phpcr_namespace_unregister.feature rename to features/all/phpcr_namespace_unregister.feature diff --git a/features/phpcr_node_clone.feature b/features/all/phpcr_node_clone.feature similarity index 100% rename from features/phpcr_node_clone.feature rename to features/all/phpcr_node_clone.feature diff --git a/features/phpcr_node_copy.feature b/features/all/phpcr_node_copy.feature similarity index 100% rename from features/phpcr_node_copy.feature rename to features/all/phpcr_node_copy.feature diff --git a/features/phpcr_node_corresponding.feature b/features/all/phpcr_node_corresponding.feature similarity index 100% rename from features/phpcr_node_corresponding.feature rename to features/all/phpcr_node_corresponding.feature diff --git a/features/phpcr_node_create.feature b/features/all/phpcr_node_create.feature similarity index 100% rename from features/phpcr_node_create.feature rename to features/all/phpcr_node_create.feature diff --git a/features/phpcr_node_definition.feature b/features/all/phpcr_node_definition.feature similarity index 100% rename from features/phpcr_node_definition.feature rename to features/all/phpcr_node_definition.feature diff --git a/features/phpcr_node_edit.feature b/features/all/phpcr_node_edit.feature similarity index 100% rename from features/phpcr_node_edit.feature rename to features/all/phpcr_node_edit.feature diff --git a/features/phpcr_node_info.feature b/features/all/phpcr_node_info.feature similarity index 100% rename from features/phpcr_node_info.feature rename to features/all/phpcr_node_info.feature diff --git a/features/phpcr_node_lifecycle_follow_transition.feature b/features/all/phpcr_node_lifecycle_follow_transition.feature similarity index 100% rename from features/phpcr_node_lifecycle_follow_transition.feature rename to features/all/phpcr_node_lifecycle_follow_transition.feature diff --git a/features/phpcr_node_lifecycle_list.feature b/features/all/phpcr_node_lifecycle_list.feature similarity index 100% rename from features/phpcr_node_lifecycle_list.feature rename to features/all/phpcr_node_lifecycle_list.feature diff --git a/features/phpcr_node_list.feature b/features/all/phpcr_node_list.feature similarity index 100% rename from features/phpcr_node_list.feature rename to features/all/phpcr_node_list.feature diff --git a/features/phpcr_node_mixin_add.feature b/features/all/phpcr_node_mixin_add.feature similarity index 100% rename from features/phpcr_node_mixin_add.feature rename to features/all/phpcr_node_mixin_add.feature diff --git a/features/phpcr_node_mixin_remove.feature b/features/all/phpcr_node_mixin_remove.feature similarity index 100% rename from features/phpcr_node_mixin_remove.feature rename to features/all/phpcr_node_mixin_remove.feature diff --git a/features/phpcr_node_move.feature b/features/all/phpcr_node_move.feature similarity index 68% rename from features/phpcr_node_move.feature rename to features/all/phpcr_node_move.feature index 156dcbeb..18aadf84 100644 --- a/features/phpcr_node_move.feature +++ b/features/all/phpcr_node_move.feature @@ -5,17 +5,17 @@ Feature: Move a node in the current session Background: Given that I am logged in as "testuser" - And the "session_data.xml" fixtures are loaded + And the "cms.xml" fixtures are loaded Scenario: Move node - Given I execute the "node:move /tests_general_base/index.txt /foobar" command + Given I execute the "node:move /cms/test /foobar" command Then the command should not fail And I execute the "session:save" command And there should exist a node at "/foobar" And there should not exist a node at "/tests_general_base/index.txt" Scenario: Move node relative paths - Given the current node is "/tests_general_base/index.txt" + Given the current node is "/cms/test" And I execute the "node:move . /barfoo" command Then the command should not fail And I execute the "session:save" command @@ -23,8 +23,8 @@ Feature: Move a node in the current session And there should not exist a node at "/tests_general_base/index.txt" Scenario: Move onto existing target - Given the current node is "/tests_general_base/index.txt" - And I execute the "node:move . /tests_general_base/daniel" command + Given the current node is "/cms/test" + And I execute the "node:move . /cms/products" command Then the command should not fail And I execute the "session:save" command - And there should exist a node at "/tests_general_base/daniel/index.txt" + And there should exist a node at "/cms/products/test" diff --git a/features/phpcr_node_property_remove.feature b/features/all/phpcr_node_property_remove.feature similarity index 91% rename from features/phpcr_node_property_remove.feature rename to features/all/phpcr_node_property_remove.feature index 13cd5bc0..58fc8d27 100644 --- a/features/phpcr_node_property_remove.feature +++ b/features/all/phpcr_node_property_remove.feature @@ -14,7 +14,7 @@ Feature: Remove a single property at a specified path And there should not exist a property at "/cms/articles/article1/title" Scenario: Try and remove a node - And I execute the "node:property:remove /tests_general_base" command + Given I execute the "node:property:remove /tests_general_base" command Then the command should fail And I should see the following: """ diff --git a/features/phpcr_node_property_set.feature b/features/all/phpcr_node_property_set.feature similarity index 100% rename from features/phpcr_node_property_set.feature rename to features/all/phpcr_node_property_set.feature diff --git a/features/phpcr_node_property_show.feature b/features/all/phpcr_node_property_show.feature similarity index 100% rename from features/phpcr_node_property_show.feature rename to features/all/phpcr_node_property_show.feature diff --git a/features/phpcr_node_references.feature b/features/all/phpcr_node_references.feature similarity index 100% rename from features/phpcr_node_references.feature rename to features/all/phpcr_node_references.feature diff --git a/features/phpcr_node_remove.feature b/features/all/phpcr_node_remove.feature similarity index 100% rename from features/phpcr_node_remove.feature rename to features/all/phpcr_node_remove.feature diff --git a/features/phpcr_node_rename.feature b/features/all/phpcr_node_rename.feature similarity index 100% rename from features/phpcr_node_rename.feature rename to features/all/phpcr_node_rename.feature diff --git a/features/phpcr_node_reorder_before.feature b/features/all/phpcr_node_reorder_before.feature similarity index 100% rename from features/phpcr_node_reorder_before.feature rename to features/all/phpcr_node_reorder_before.feature diff --git a/features/phpcr_node_set_primary_type.feature b/features/all/phpcr_node_set_primary_type.feature similarity index 100% rename from features/phpcr_node_set_primary_type.feature rename to features/all/phpcr_node_set_primary_type.feature diff --git a/features/phpcr_node_shared_remove.feature b/features/all/phpcr_node_shared_remove.feature similarity index 100% rename from features/phpcr_node_shared_remove.feature rename to features/all/phpcr_node_shared_remove.feature diff --git a/features/phpcr_node_shared_show.feature b/features/all/phpcr_node_shared_show.feature similarity index 100% rename from features/phpcr_node_shared_show.feature rename to features/all/phpcr_node_shared_show.feature diff --git a/features/phpcr_node_type_edit.feature b/features/all/phpcr_node_type_edit.feature similarity index 100% rename from features/phpcr_node_type_edit.feature rename to features/all/phpcr_node_type_edit.feature diff --git a/features/phpcr_node_type_list.feature b/features/all/phpcr_node_type_list.feature similarity index 100% rename from features/phpcr_node_type_list.feature rename to features/all/phpcr_node_type_list.feature diff --git a/features/phpcr_node_type_load.feature b/features/all/phpcr_node_type_load.feature similarity index 100% rename from features/phpcr_node_type_load.feature rename to features/all/phpcr_node_type_load.feature diff --git a/features/phpcr_node_type_show.feature b/features/all/phpcr_node_type_show.feature similarity index 100% rename from features/phpcr_node_type_show.feature rename to features/all/phpcr_node_type_show.feature diff --git a/features/phpcr_node_type_unregister.feature b/features/all/phpcr_node_type_unregister.feature similarity index 88% rename from features/phpcr_node_type_unregister.feature rename to features/all/phpcr_node_type_unregister.feature index f5c9a7c3..b8be24e3 100644 --- a/features/phpcr_node_type_unregister.feature +++ b/features/all/phpcr_node_type_unregister.feature @@ -3,6 +3,8 @@ Feature: Unregister a node type As a user that is logged into the shell I need to be able to do that + # This is not currently implemented by Jackrabbit + Background: Given that I am logged in as "testuser" @@ -10,10 +12,6 @@ Feature: Unregister a node type Given the "example.cnd" node type is loaded And I execute the "node-type:unregister ns:NodeType" command Then the command should fail - And I should see the following: - """ - NodeType not found - """ Scenario: Attempt to unregister a non-registered node type Given the "example.cnd" node type is loaded diff --git a/features/phpcr_node_update.feature b/features/all/phpcr_node_update.feature similarity index 100% rename from features/phpcr_node_update.feature rename to features/all/phpcr_node_update.feature diff --git a/features/phpcr_query.feature b/features/all/phpcr_query.feature similarity index 100% rename from features/phpcr_query.feature rename to features/all/phpcr_query.feature diff --git a/features/phpcr_query_delete.feature b/features/all/phpcr_query_delete.feature similarity index 100% rename from features/phpcr_query_delete.feature rename to features/all/phpcr_query_delete.feature diff --git a/features/phpcr_query_select.feature b/features/all/phpcr_query_select.feature similarity index 100% rename from features/phpcr_query_select.feature rename to features/all/phpcr_query_select.feature diff --git a/features/phpcr_query_update.feature b/features/all/phpcr_query_update.feature similarity index 100% rename from features/phpcr_query_update.feature rename to features/all/phpcr_query_update.feature diff --git a/features/phpcr_repository_descriptor_list.feature b/features/all/phpcr_repository_descriptor_list.feature similarity index 100% rename from features/phpcr_repository_descriptor_list.feature rename to features/all/phpcr_repository_descriptor_list.feature diff --git a/features/phpcr_retention_hold_add.feature b/features/all/phpcr_retention_hold_add.feature similarity index 100% rename from features/phpcr_retention_hold_add.feature rename to features/all/phpcr_retention_hold_add.feature diff --git a/features/phpcr_retention_hold_list.feature b/features/all/phpcr_retention_hold_list.feature similarity index 100% rename from features/phpcr_retention_hold_list.feature rename to features/all/phpcr_retention_hold_list.feature diff --git a/features/phpcr_retention_hold_remove.feature b/features/all/phpcr_retention_hold_remove.feature similarity index 100% rename from features/phpcr_retention_hold_remove.feature rename to features/all/phpcr_retention_hold_remove.feature diff --git a/features/phpcr_retention_policy_get.feature b/features/all/phpcr_retention_policy_get.feature similarity index 100% rename from features/phpcr_retention_policy_get.feature rename to features/all/phpcr_retention_policy_get.feature diff --git a/features/phpcr_retention_policy_remove.feature b/features/all/phpcr_retention_policy_remove.feature similarity index 100% rename from features/phpcr_retention_policy_remove.feature rename to features/all/phpcr_retention_policy_remove.feature diff --git a/features/phpcr_session_export_view.feature b/features/all/phpcr_session_export_view.feature similarity index 100% rename from features/phpcr_session_export_view.feature rename to features/all/phpcr_session_export_view.feature diff --git a/features/phpcr_session_impersonate.feature b/features/all/phpcr_session_impersonate.feature similarity index 100% rename from features/phpcr_session_impersonate.feature rename to features/all/phpcr_session_impersonate.feature diff --git a/features/phpcr_session_import.feature b/features/all/phpcr_session_import.feature similarity index 100% rename from features/phpcr_session_import.feature rename to features/all/phpcr_session_import.feature diff --git a/features/phpcr_session_info.feature b/features/all/phpcr_session_info.feature similarity index 100% rename from features/phpcr_session_info.feature rename to features/all/phpcr_session_info.feature diff --git a/features/phpcr_session_namespace_list.feature b/features/all/phpcr_session_namespace_list.feature similarity index 100% rename from features/phpcr_session_namespace_list.feature rename to features/all/phpcr_session_namespace_list.feature diff --git a/features/phpcr_session_namespace_set.feature b/features/all/phpcr_session_namespace_set.feature similarity index 100% rename from features/phpcr_session_namespace_set.feature rename to features/all/phpcr_session_namespace_set.feature diff --git a/features/phpcr_session_refresh.feature b/features/all/phpcr_session_refresh.feature similarity index 100% rename from features/phpcr_session_refresh.feature rename to features/all/phpcr_session_refresh.feature diff --git a/features/phpcr_session_save.feature b/features/all/phpcr_session_save.feature similarity index 100% rename from features/phpcr_session_save.feature rename to features/all/phpcr_session_save.feature diff --git a/features/phpcr_version_checkin.feature b/features/all/phpcr_version_checkin.feature similarity index 100% rename from features/phpcr_version_checkin.feature rename to features/all/phpcr_version_checkin.feature diff --git a/features/phpcr_version_checkout.feature b/features/all/phpcr_version_checkout.feature similarity index 100% rename from features/phpcr_version_checkout.feature rename to features/all/phpcr_version_checkout.feature diff --git a/features/phpcr_version_checkpoint.feature b/features/all/phpcr_version_checkpoint.feature similarity index 100% rename from features/phpcr_version_checkpoint.feature rename to features/all/phpcr_version_checkpoint.feature diff --git a/features/phpcr_version_history.feature b/features/all/phpcr_version_history.feature similarity index 100% rename from features/phpcr_version_history.feature rename to features/all/phpcr_version_history.feature diff --git a/features/phpcr_version_remove.feature b/features/all/phpcr_version_remove.feature similarity index 100% rename from features/phpcr_version_remove.feature rename to features/all/phpcr_version_remove.feature diff --git a/features/phpcr_version_restore.feature b/features/all/phpcr_version_restore.feature similarity index 100% rename from features/phpcr_version_restore.feature rename to features/all/phpcr_version_restore.feature diff --git a/features/shell_alias.feature b/features/shell/shell_alias.feature similarity index 97% rename from features/shell_alias.feature rename to features/shell/shell_alias.feature index b22eb82a..5058552e 100644 --- a/features/shell_alias.feature +++ b/features/shell/shell_alias.feature @@ -18,7 +18,6 @@ Feature: Command aliases Examples: | command | - | use default | | select * from [nt:unstructured] | | cd cms | | rm cms | diff --git a/features/shell_autocomplete.feature b/features/shell/shell_autocomplete.feature similarity index 100% rename from features/shell_autocomplete.feature rename to features/shell/shell_autocomplete.feature diff --git a/features/shell_clear.feature b/features/shell/shell_clear.feature similarity index 100% rename from features/shell_clear.feature rename to features/shell/shell_clear.feature diff --git a/features/shell_config_init.feature b/features/shell/shell_config_init.feature similarity index 100% rename from features/shell_config_init.feature rename to features/shell/shell_config_init.feature diff --git a/features/shell_config_reload.feature b/features/shell/shell_config_reload.feature similarity index 100% rename from features/shell_config_reload.feature rename to features/shell/shell_config_reload.feature diff --git a/features/shell_exit.feature b/features/shell/shell_exit.feature similarity index 100% rename from features/shell_exit.feature rename to features/shell/shell_exit.feature diff --git a/features/shell_path_change.feature b/features/shell/shell_path_change.feature similarity index 100% rename from features/shell_path_change.feature rename to features/shell/shell_path_change.feature diff --git a/features/phpcr_session_login.feature b/features/standalone/phpcr_session_login.feature similarity index 98% rename from features/phpcr_session_login.feature rename to features/standalone/phpcr_session_login.feature index 698b0f11..7f8225fc 100644 --- a/features/phpcr_session_login.feature +++ b/features/standalone/phpcr_session_login.feature @@ -1,3 +1,4 @@ +@standlone Feature: Login to the session In order to reconnect as a different user from a session As a user logged into the shell diff --git a/features/phpcr_session_logout.feature b/features/standalone/phpcr_session_logout.feature similarity index 100% rename from features/phpcr_session_logout.feature rename to features/standalone/phpcr_session_logout.feature diff --git a/features/phpcr_workspace_create.feature b/features/standalone/phpcr_workspace_create.feature similarity index 100% rename from features/phpcr_workspace_create.feature rename to features/standalone/phpcr_workspace_create.feature diff --git a/features/phpcr_workspace_delete.feature b/features/standalone/phpcr_workspace_delete.feature similarity index 100% rename from features/phpcr_workspace_delete.feature rename to features/standalone/phpcr_workspace_delete.feature diff --git a/features/phpcr_workspace_list.feature b/features/standalone/phpcr_workspace_list.feature similarity index 100% rename from features/phpcr_workspace_list.feature rename to features/standalone/phpcr_workspace_list.feature diff --git a/features/phpcr_workspace_namespace_list.feature b/features/standalone/phpcr_workspace_namespace_list.feature similarity index 100% rename from features/phpcr_workspace_namespace_list.feature rename to features/standalone/phpcr_workspace_namespace_list.feature diff --git a/features/phpcr_workspace_namespace_register.feature b/features/standalone/phpcr_workspace_namespace_register.feature similarity index 100% rename from features/phpcr_workspace_namespace_register.feature rename to features/standalone/phpcr_workspace_namespace_register.feature diff --git a/features/phpcr_workspace_namespace_unregister.feature b/features/standalone/phpcr_workspace_namespace_unregister.feature similarity index 100% rename from features/phpcr_workspace_namespace_unregister.feature rename to features/standalone/phpcr_workspace_namespace_unregister.feature diff --git a/features/phpcr_workspace_use.feature b/features/standalone/phpcr_workspace_use.feature similarity index 100% rename from features/phpcr_workspace_use.feature rename to features/standalone/phpcr_workspace_use.feature diff --git a/spec/PHPCR/Shell/Console/Helper/ConfigHelperSpec.php b/spec/PHPCR/Shell/Config/ConfigManagerSpec.php similarity index 58% rename from spec/PHPCR/Shell/Console/Helper/ConfigHelperSpec.php rename to spec/PHPCR/Shell/Config/ConfigManagerSpec.php index c5b33d27..6530ad30 100644 --- a/spec/PHPCR/Shell/Console/Helper/ConfigHelperSpec.php +++ b/spec/PHPCR/Shell/Config/ConfigManagerSpec.php @@ -1,32 +1,32 @@ beConstructedWith($filesystem); } - function it_is_initializable() + public function it_is_initializable() { - $this->shouldHaveType('PHPCR\Shell\Console\Helper\ConfigHelper'); + $this->shouldHaveType('PHPCR\Shell\Config\ConfigManager'); } - function it_should_have_a_method_to_get_the_users_config_directory() + public function it_should_have_a_method_to_get_the_users_config_directory() { putenv('PHPCRSH_HOME=/home/foobar'); $this->getConfigDir()->shouldReturn('/home/foobar'); } - function it_should_be_able_to_parse_a_config_file_and_return_the_config_as_an_array( + public function it_should_be_able_to_parse_a_config_file_and_return_the_config_as_an_array( Filesystem $filesystem ) { @@ -34,7 +34,7 @@ function it_should_be_able_to_parse_a_config_file_and_return_the_config_as_an_ar putenv('PHPCRSH_HOME=' . $dir); $filesystem->exists(Argument::any())->willReturn(true); - $config = $this->getConfig('alias')->shouldReturn(array( + $this->getConfig('alias')->shouldReturn(array( 'foobar' => 'barfoo', 'barfoo' => 'foobar', )); diff --git a/spec/PHPCR/Shell/Config/ProfileLoaderSpec.php b/spec/PHPCR/Shell/Config/ProfileLoaderSpec.php index ff69f7b1..6c61d7ac 100644 --- a/spec/PHPCR/Shell/Config/ProfileLoaderSpec.php +++ b/spec/PHPCR/Shell/Config/ProfileLoaderSpec.php @@ -4,34 +4,34 @@ use PhpSpec\ObjectBehavior; use Prophecy\Argument; -use PHPCR\Shell\Console\Helper\ConfigHelper; +use PHPCR\Shell\Config\ConfigManager; use PHPCR\Shell\Config\Profile; use Symfony\Component\Filesystem\Filesystem; class ProfileLoaderSpec extends ObjectBehavior { - function let( - ConfigHelper $configHelper, + public function let( + ConfigManager $configManager, Filesystem $filesystem ) { - $configHelper->getConfigDir()->willReturn(__DIR__); - $this->beConstructedWith($configHelper, $filesystem); + $configManager->getConfigDir()->willReturn(__DIR__); + $this->beConstructedWith($configManager, $filesystem); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Config\ProfileLoader'); } - function it_should_list_profile_names() + public function it_should_list_profile_names() { $this->getProfileNames()->shouldReturn(array( 'one', 'two' )); } - function it_should_load_data_into_a_given_profile( + public function it_should_load_data_into_a_given_profile( Profile $profile, Filesystem $filesystem ) @@ -51,7 +51,7 @@ function it_should_load_data_into_a_given_profile( $this->loadProfile($profile); } - function it_should_save_a_given_profile( + public function it_should_save_a_given_profile( Profile $profile, Filesystem $filesystem ) diff --git a/spec/PHPCR/Shell/Config/ProfileSpec.php b/spec/PHPCR/Shell/Config/ProfileSpec.php index db87badf..9113deba 100644 --- a/spec/PHPCR/Shell/Config/ProfileSpec.php +++ b/spec/PHPCR/Shell/Config/ProfileSpec.php @@ -3,30 +3,28 @@ namespace spec\PHPCR\Shell\Config; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; -use PHPCR\Shell\Transport\TransportConfig; class ProfileSpec extends ObjectBehavior { - function let() + public function let() { $this->beConstructedWith( 'foobar' ); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Config\Profile'); } - function it_has_a_method_to_set_config( + public function it_has_a_method_to_set_config( ) { $this->set('transport', array()); } - function it_has_a_method_to_get_config() + public function it_has_a_method_to_get_config() { $this->set('transport', array( 'foo' => 'bar' diff --git a/spec/PHPCR/Shell/Console/Helper/fixtures/config/alias.yml b/spec/PHPCR/Shell/Config/fixtures/config/alias.yml similarity index 100% rename from spec/PHPCR/Shell/Console/Helper/fixtures/config/alias.yml rename to spec/PHPCR/Shell/Config/fixtures/config/alias.yml diff --git a/spec/PHPCR/Shell/Config/profiles/one.yml b/spec/PHPCR/Shell/Config/profiles/one.yml index 5bdd4eaa..fd6290f5 100644 --- a/spec/PHPCR/Shell/Config/profiles/one.yml +++ b/spec/PHPCR/Shell/Config/profiles/one.yml @@ -1,4 +1,4 @@ -transport: +transport: name: foobar bar_foo: barfoo foo_bar: foobar diff --git a/spec/PHPCR/Shell/Console/Application/EmbeddedApplicationSpec.php b/spec/PHPCR/Shell/Console/Application/EmbeddedApplicationSpec.php index 0fe61b98..83c98832 100644 --- a/spec/PHPCR/Shell/Console/Application/EmbeddedApplicationSpec.php +++ b/spec/PHPCR/Shell/Console/Application/EmbeddedApplicationSpec.php @@ -3,17 +3,19 @@ namespace spec\PHPCR\Shell\Console\Application; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; use PHPCR\Shell\Console\Application\EmbeddedApplication; +use Symfony\Component\DependencyInjection\ContainerInterface; class EmbeddedApplicationSpec extends ObjectBehavior { - function let() + public function let( + ContainerInterface $container + ) { - $this->beConstructedWith(EmbeddedApplication::MODE_COMMAND); + $this->beConstructedWith($container, EmbeddedApplication::MODE_COMMAND); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Console\Application\EmbeddedApplication'); } diff --git a/spec/PHPCR/Shell/Console/Application/ShellApplicationSpec.php b/spec/PHPCR/Shell/Console/Application/ShellApplicationSpec.php index c2f1bf2c..6f4b7964 100644 --- a/spec/PHPCR/Shell/Console/Application/ShellApplicationSpec.php +++ b/spec/PHPCR/Shell/Console/Application/ShellApplicationSpec.php @@ -3,11 +3,19 @@ namespace spec\PHPCR\Shell\Console\Application; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; +use Symfony\Component\DependencyInjection\ContainerInterface; +use PHPCR\Shell\Console\Application\EmbeddedApplication; class ShellApplicationSpec extends ObjectBehavior { - function it_is_initializable() + public function let( + ContainerInterface $container + ) + { + $this->beConstructedWith($container, EmbeddedApplication::MODE_COMMAND); + } + + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Console\Application\ShellApplication'); } diff --git a/spec/PHPCR/Shell/Console/Helper/EditorHelperSpec.php b/spec/PHPCR/Shell/Console/Helper/EditorHelperSpec.php index f2b1f65a..747d99c1 100644 --- a/spec/PHPCR/Shell/Console/Helper/EditorHelperSpec.php +++ b/spec/PHPCR/Shell/Console/Helper/EditorHelperSpec.php @@ -3,11 +3,10 @@ namespace spec\PHPCR\Shell\Console\Helper; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class EditorHelperSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Console\Helper\EditorHelper'); } diff --git a/spec/PHPCR/Shell/Console/Helper/NodeHelperSpec.php b/spec/PHPCR/Shell/Console/Helper/NodeHelperSpec.php index 2fb91425..11de739b 100644 --- a/spec/PHPCR/Shell/Console/Helper/NodeHelperSpec.php +++ b/spec/PHPCR/Shell/Console/Helper/NodeHelperSpec.php @@ -3,18 +3,17 @@ namespace spec\PHPCR\Shell\Console\Helper; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; use PHPCR\NodeInterface; use PHPCR\NodeType\NodeTypeInterface; class NodeHelperSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Console\Helper\NodeHelper'); } - function it_should_provide_a_method_to_determine_if_a_node_has_a_given_mixin( + public function it_should_provide_a_method_to_determine_if_a_node_has_a_given_mixin( NodeInterface $node, NodeTypeInterface $mixin1, NodeTypeInterface $mixin2, @@ -33,7 +32,7 @@ function it_should_provide_a_method_to_determine_if_a_node_has_a_given_mixin( $this->nodeHasMixinType($node, 'mixin5')->shouldReturn(false); } - function it_should_provide_a_method_to_determine_if_a_node_is_versionable( + public function it_should_provide_a_method_to_determine_if_a_node_is_versionable( NodeInterface $nodeVersionable, NodeInterface $nodeNotVersionable, NodeTypeInterface $mixin1, diff --git a/spec/PHPCR/Shell/Console/Helper/PathHelperSpec.php b/spec/PHPCR/Shell/Console/Helper/PathHelperSpec.php index 333d904c..dd739306 100644 --- a/spec/PHPCR/Shell/Console/Helper/PathHelperSpec.php +++ b/spec/PHPCR/Shell/Console/Helper/PathHelperSpec.php @@ -3,21 +3,20 @@ namespace spec\PHPCR\Shell\Console\Helper; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class PathHelperSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Console\Helper\PathHelper'); } - function it_has_a_method_to_provide_the_parent_path_for_a_given_path() + public function it_has_a_method_to_provide_the_parent_path_for_a_given_path() { $this->getParentPath('/foo/bar')->shouldReturn('/foo'); } - function it_has_a_method_to_get_the_node_name_of_a_given_path() + public function it_has_a_method_to_get_the_node_name_of_a_given_path() { $this->getNodeName('/foo/bar')->shouldReturn('bar'); } diff --git a/spec/PHPCR/Shell/Console/Helper/RepositoryHelperSpec.php b/spec/PHPCR/Shell/Console/Helper/RepositoryHelperSpec.php index 7ebe692f..7ee9b762 100644 --- a/spec/PHPCR/Shell/Console/Helper/RepositoryHelperSpec.php +++ b/spec/PHPCR/Shell/Console/Helper/RepositoryHelperSpec.php @@ -3,28 +3,27 @@ namespace spec\PHPCR\Shell\Console\Helper; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; use PHPCR\RepositoryInterface; -use PHPCR\Shell\Console\Helper\PhpcrHelper; +use PHPCR\Shell\Phpcr\SessionManager; class RepositoryHelperSpec extends ObjectBehavior { - function let( - PhpcrHelper $phpcrHelper + public function let( + SessionManager $sessionManager ) { - $this->beConstructedWith($phpcrHelper); + $this->beConstructedWith($sessionManager); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Console\Helper\RepositoryHelper'); } - function it_provides_a_method_to_say_if_a_descriptor_exists_or_not( - PhpcrHelper $phpcrHelper, + public function it_provides_a_method_to_say_if_a_descriptor_exists_or_not( + SessionManager $sessionManager, RepositoryInterface $repository ) { - $phpcrHelper->getRepository()->willReturn($repository); + $sessionManager->getRepository()->willReturn($repository); $repository->getDescriptorKeys()->willReturn(array( 'foo', 'bar' )); diff --git a/spec/PHPCR/Shell/Console/Helper/ResultFormatterHelperSpec.php b/spec/PHPCR/Shell/Console/Helper/ResultFormatterHelperSpec.php index 6590a4ce..8497642c 100644 --- a/spec/PHPCR/Shell/Console/Helper/ResultFormatterHelperSpec.php +++ b/spec/PHPCR/Shell/Console/Helper/ResultFormatterHelperSpec.php @@ -3,19 +3,20 @@ namespace spec\PHPCR\Shell\Console\Helper; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; use PHPCR\Shell\Console\Helper\TextHelper; +use PHPCR\Shell\Console\Helper\TableHelper; class ResultFormatterHelperSpec extends ObjectBehavior { - function let( - TextHelper $textHelper + public function let( + TextHelper $textHelper, + TableHelper $tableHelper ) { - $this->beConstructedWith($textHelper); + $this->beConstructedWith($textHelper, $tableHelper); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Console\Helper\ResultFormatterHelper'); } diff --git a/spec/PHPCR/Shell/Console/Helper/TextHelperSpec.php b/spec/PHPCR/Shell/Console/Helper/TextHelperSpec.php index 85dd1921..8a38160e 100644 --- a/spec/PHPCR/Shell/Console/Helper/TextHelperSpec.php +++ b/spec/PHPCR/Shell/Console/Helper/TextHelperSpec.php @@ -3,16 +3,15 @@ namespace spec\PHPCR\Shell\Console\Helper; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class TextHelperSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Console\Helper\TextHelper'); } - function it_should_truncate_text() + public function it_should_truncate_text() { $this->truncate('hello this is some text', 5)->shouldReturn('he...'); } diff --git a/spec/PHPCR/Shell/Console/Input/StringInputSpec.php b/spec/PHPCR/Shell/Console/Input/StringInputSpec.php index 9cf31c0c..614b6991 100644 --- a/spec/PHPCR/Shell/Console/Input/StringInputSpec.php +++ b/spec/PHPCR/Shell/Console/Input/StringInputSpec.php @@ -3,16 +3,15 @@ namespace spec\PHPCR\Shell\Console\Input; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class StringInputSpec extends ObjectBehavior { - function let() + public function let() { $this->beConstructedWith('foobar'); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Console\Input\StringInput'); } diff --git a/spec/PHPCR/Shell/Event/ApplicationInitEventSpec.php b/spec/PHPCR/Shell/Event/ApplicationInitEventSpec.php index f91a457e..1294fbdf 100644 --- a/spec/PHPCR/Shell/Event/ApplicationInitEventSpec.php +++ b/spec/PHPCR/Shell/Event/ApplicationInitEventSpec.php @@ -3,24 +3,23 @@ namespace spec\PHPCR\Shell\Event; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; use Symfony\Component\Console\Application; class ApplicationInitEventSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Event\ApplicationInitEvent'); } - function let( + public function let( Application $application ) { $this->beConstructedWith($application); } - function it_will_return_the_application( + public function it_will_return_the_application( Application $application ) { diff --git a/spec/PHPCR/Shell/Event/CommandExceptionEventSpec.php b/spec/PHPCR/Shell/Event/CommandExceptionEventSpec.php index fa74842c..c6c41cc4 100644 --- a/spec/PHPCR/Shell/Event/CommandExceptionEventSpec.php +++ b/spec/PHPCR/Shell/Event/CommandExceptionEventSpec.php @@ -3,26 +3,25 @@ namespace spec\PHPCR\Shell\Event; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use PHPCR\Shell\Console\Application\ShellApplication; class CommandExceptionEventSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Event\CommandExceptionEvent'); } - function let( + public function let( \Exception $exception, - InputInterface $input, + ShellApplication $application, OutputInterface $output ) { - $this->beConstructedWith($exception, $input, $output); + $this->beConstructedWith($exception, $application, $output); } - function it_should_provide_access_to_event_parameters( + public function it_should_provide_access_to_event_parameters( \Exception $exception, OutputInterface $output ) { diff --git a/spec/PHPCR/Shell/Event/ProfileInitEventSpec.php b/spec/PHPCR/Shell/Event/ProfileInitEventSpec.php index 9b07c8d7..8c686b26 100644 --- a/spec/PHPCR/Shell/Event/ProfileInitEventSpec.php +++ b/spec/PHPCR/Shell/Event/ProfileInitEventSpec.php @@ -3,30 +3,29 @@ namespace spec\PHPCR\Shell\Event; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; use PHPCR\Shell\Config\Profile; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class ProfileInitEventSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Event\ProfileInitEvent'); } - function let( + public function let( Profile $profile, InputInterface $input, OutputInterface $output - ) + ) { $this->beConstructedWith( $profile, $input, $output ); } - function it_should_have_getters( + public function it_should_have_getters( Profile $profile, InputInterface $input, OutputInterface $output diff --git a/spec/PHPCR/Shell/Console/Helper/PhpcrHelperSpec.php b/spec/PHPCR/Shell/Phpcr/SessionManagerSpec.php similarity index 55% rename from spec/PHPCR/Shell/Console/Helper/PhpcrHelperSpec.php rename to spec/PHPCR/Shell/Phpcr/SessionManagerSpec.php index 334d4c2e..d60c9129 100644 --- a/spec/PHPCR/Shell/Console/Helper/PhpcrHelperSpec.php +++ b/spec/PHPCR/Shell/Phpcr/SessionManagerSpec.php @@ -1,23 +1,22 @@ beConstructedWith($transportRegistry, $profile); } - function it_is_initializable() + public function it_is_initializable() { - $this->shouldHaveType('PHPCR\Shell\Console\Helper\PhpcrHelper'); + $this->shouldHaveType('PHPCR\Shell\Phpcr\SessionManager'); } } diff --git a/spec/PHPCR/Shell/Query/UpdateParserSpec.php b/spec/PHPCR/Shell/Query/UpdateParserSpec.php index c0e05d53..7c122bf4 100644 --- a/spec/PHPCR/Shell/Query/UpdateParserSpec.php +++ b/spec/PHPCR/Shell/Query/UpdateParserSpec.php @@ -3,7 +3,6 @@ namespace spec\PHPCR\Shell\Query; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; use PHPCR\Query\QOM\QueryObjectModelFactoryInterface; use PHPCR\Query\QOM\JoinInterface; use PHPCR\Query\QOM\SourceInterface; @@ -13,12 +12,10 @@ use PHPCR\Query\QOM\LiteralInterface; use PHPCR\Query\QOM\ComparisonInterface; use PHPCR\Query\QueryInterface; -use PHPCR\Shell\Query\FunctionOperand; -use PHPCR\Shell\Query\ColumnOperand; class UpdateParserSpec extends ObjectBehavior { - function let( + public function let( QueryObjectModelFactoryInterface $qomf ) { @@ -27,12 +24,12 @@ function let( ); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Query\UpdateParser'); } - function it_should_provide_a_qom_object_for_selecting( + public function it_should_provide_a_qom_object_for_selecting( QueryObjectModelFactoryInterface $qomf, ChildNodeJoinConditionInterface $joinCondition, JoinInterface $join, @@ -54,11 +51,10 @@ function it_should_provide_a_qom_object_for_selecting( $qomf->createQuery($join, $comparison)->willReturn($query); - $sql = <<shouldHaveType('PHPCR\Shell\Serializer\NodeNormalizer'); } - function it_can_normalize_a_node_to_an_array( + public function it_can_normalize_a_node_to_an_array( NodeInterface $node, PropertyInterface $p1, PropertyInterface $p2, PropertyInterface $p3 - ) + ) { $node->getProperties()->willReturn(array( $p1, $p2, $p3 diff --git a/spec/PHPCR/Shell/Serializer/YamlEncoderSpec.php b/spec/PHPCR/Shell/Serializer/YamlEncoderSpec.php index 4959f7a6..710cf6f6 100644 --- a/spec/PHPCR/Shell/Serializer/YamlEncoderSpec.php +++ b/spec/PHPCR/Shell/Serializer/YamlEncoderSpec.php @@ -3,16 +3,15 @@ namespace spec\PHPCR\Shell\Serializer; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class YamlEncoderSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Serializer\YamlEncoder'); } - function it_should_encode_to_yaml() + public function it_should_encode_to_yaml() { $data = array('foobar' => 'barfoo', 'barfoo' => 'foobar'); $this->encode($data, 'yaml')->shouldReturn(<<shouldHaveType('PHPCR\Shell\Subscriber\AliasSubscriber'); } - function let( - HelperSet $helperSet, - ConfigHelper $config + public function let( + ConfigManager $config ) { - $helperSet->get('config')->willReturn($config); - $this->beConstructedWith( - $helperSet + $config ); $config->getConfig('alias')->willReturn(array( @@ -32,9 +28,8 @@ function let( )); } - function it_should_convert_an_aliased_input_into_a_real_command_input( + public function it_should_convert_an_aliased_input_into_a_real_command_input( CommandPreRunEvent $event, - ConfigHelper $config, StringInput $input ) { $event->getInput()->willReturn($input); @@ -47,9 +42,8 @@ function it_should_convert_an_aliased_input_into_a_real_command_input( $this->handleAlias($event)->shouldReturn('list:command me'); } - function it_should_ommit_missing_arguments( + public function it_should_ommit_missing_arguments( CommandPreRunEvent $event, - ConfigHelper $config, StringInput $input ) { $event->getInput()->willReturn($input); diff --git a/spec/PHPCR/Shell/Transport/Transport/DoctrineDbalSpec.php b/spec/PHPCR/Shell/Transport/Transport/DoctrineDbalSpec.php index fcbfef32..6d8b7475 100644 --- a/spec/PHPCR/Shell/Transport/Transport/DoctrineDbalSpec.php +++ b/spec/PHPCR/Shell/Transport/Transport/DoctrineDbalSpec.php @@ -3,11 +3,10 @@ namespace spec\PHPCR\Shell\Transport\Transport; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class DoctrineDbalSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Transport\Transport\DoctrineDbal'); } diff --git a/spec/PHPCR/Shell/Transport/Transport/JackrabbitSpec.php b/spec/PHPCR/Shell/Transport/Transport/JackrabbitSpec.php index 6e803124..ffb881ae 100644 --- a/spec/PHPCR/Shell/Transport/Transport/JackrabbitSpec.php +++ b/spec/PHPCR/Shell/Transport/Transport/JackrabbitSpec.php @@ -3,11 +3,10 @@ namespace spec\PHPCR\Shell\Transport\Transport; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class JackrabbitSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Transport\Transport\Jackrabbit'); } diff --git a/spec/PHPCR/Shell/Transport/TransportRegistrySpec.php b/spec/PHPCR/Shell/Transport/TransportRegistrySpec.php index 0c425416..91177606 100644 --- a/spec/PHPCR/Shell/Transport/TransportRegistrySpec.php +++ b/spec/PHPCR/Shell/Transport/TransportRegistrySpec.php @@ -3,17 +3,16 @@ namespace spec\PHPCR\Shell\Transport; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; use PHPCR\Shell\Transport\TransportInterface; class TransportRegistrySpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('PHPCR\Shell\Transport\TransportRegistry'); } - function it_can_register_transports( + public function it_can_register_transports( TransportInterface $transport ) { @@ -21,7 +20,7 @@ function it_can_register_transports( $this->register($transport); } - function it_can_return_the_names_of_the_transports( + public function it_can_return_the_names_of_the_transports( TransportInterface $transport1, TransportInterface $transport2 ) @@ -36,7 +35,7 @@ function it_can_return_the_names_of_the_transports( )); } - function it_can_return_a_named_transport_object( + public function it_can_return_a_named_transport_object( TransportInterface $transport ) { diff --git a/src/PHPCR/Shell/Console/Helper/ConfigHelper.php b/src/PHPCR/Shell/Config/ConfigManager.php similarity index 83% rename from src/PHPCR/Shell/Console/Helper/ConfigHelper.php rename to src/PHPCR/Shell/Config/ConfigManager.php index d7435e43..480dc273 100644 --- a/src/PHPCR/Shell/Console/Helper/ConfigHelper.php +++ b/src/PHPCR/Shell/Config/ConfigManager.php @@ -1,19 +1,17 @@ */ -class ConfigHelper extends Helper +class ConfigManager { /** * Base filenames of all the possible configuration files @@ -39,27 +37,26 @@ class ConfigHelper extends Helper */ protected $filesystem; + /** + * @var QuestionHelper|DialogHelper + */ + protected $questionHelper; + /** * Constuctor - can optionally accept a Filesystem object * for testing purposes, otherwise one is created. * - * @param Filesystem $filesystem + * @param QuestionHelper|DialogHelper $questionHelper + * @param Filesystem $filesystem */ - public function __construct(Filesystem $filesystem = null) + public function __construct($questionHelper, Filesystem $filesystem = null) { if (null === $filesystem) { $filesystem = new Filesystem(); } $this->filesystem = $filesystem; - } - - /** - * {@inheritDoc} - */ - public function getName() - { - return 'config'; + $this->questionHelper = $questionHelper; } /** @@ -74,7 +71,6 @@ public function getConfigDir() if ($home) { return $home; } - // handle windows .. if (defined('PHP_WINDOWS_VERSION_MAJOR')) { if (!getenv('APPDATA')) { @@ -100,7 +96,7 @@ public function getConfigDir() private function getDistConfigDir() { - return __DIR__ . '/../../Resources/config.dist'; + return __DIR__ . '/../Resources/config.dist'; } /** @@ -119,9 +115,9 @@ public function loadConfig() $config[$configKey] = array(); if ($this->filesystem->exists($fullPath)) { - $config[$configKey] = Yaml::parse($fullPath); - } elseif($this->filesystem->exists($fullDistPath)) { - $config[$configKey] = Yaml::parse($fullDistPath); + $config[$configKey] = Yaml::parse(file_get_contents($fullPath)); + } elseif ($this->filesystem->exists($fullDistPath)) { + $config[$configKey] = Yaml::parse(file_get_contents($fullDistPath)); } } @@ -149,7 +145,7 @@ public function getConfig($type) /** * Initialize a configuration files */ - public function initConfig(OutputInterface $output = null, DialogHelper $dialogHelper = null, $noInteraction = false) + public function initConfig(OutputInterface $output = null, $noInteraction = false) { $log = function ($message) use ($output) { if ($output) { @@ -182,9 +178,9 @@ public function initConfig(OutputInterface $output = null, DialogHelper $dialogH } if ($this->filesystem->exists($destFile)) { - if (null !== $dialogHelper) { + if (null !== $this->questionHelper) { if (false === $noInteraction) { - $confirmed = $dialogHelper->askConfirmation( + $confirmed = $this->questionHelper->askConfirmation( $output, '"' . $configFilename . '" already exists, do you want to overwrite it?' ); diff --git a/src/PHPCR/Shell/Config/Profile.php b/src/PHPCR/Shell/Config/Profile.php index 6f124ee1..1204b62d 100644 --- a/src/PHPCR/Shell/Config/Profile.php +++ b/src/PHPCR/Shell/Config/Profile.php @@ -2,8 +2,6 @@ namespace PHPCR\Shell\Config; -use PHPCR\Shell\Transport\TransportConfig; - /** * Configuration profile object */ @@ -44,7 +42,7 @@ protected function validateDomain($domain) /** * Set a domain configuration * - * @param string $domain + * @param string $domain * @param $key * @param array|null $value * @@ -68,7 +66,7 @@ public function set($domain, $key, $value = null) * @throws \InvalidArgumentException * @return array */ - public function get($domain, $key = null) + public function get($domain, $key = null) { $this->validateDomain($domain); diff --git a/src/PHPCR/Shell/Config/ProfileLoader.php b/src/PHPCR/Shell/Config/ProfileLoader.php index 8c6f04c5..f3fae014 100644 --- a/src/PHPCR/Shell/Config/ProfileLoader.php +++ b/src/PHPCR/Shell/Config/ProfileLoader.php @@ -3,12 +3,10 @@ namespace PHPCR\Shell\Config; use PHPCR\Shell\Config\Exception\FileExistsException; -use PHPCR\Shell\Console\Helper\ConfigHelper; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Finder\Finder; use Symfony\Component\Yaml\Yaml; - class ProfileLoader { const DIR_PROFILE = 'profiles'; @@ -16,10 +14,10 @@ class ProfileLoader protected $config; protected $filesystem; - public function __construct(ConfigHelper $config, Filesystem $filesystem = null) + public function __construct(ConfigManager $config, Filesystem $filesystem = null) { $this->config = $config; - $this->filesystem = $filesystem ? : new Filesystem; + $this->filesystem = $filesystem ? : new Filesystem(); } protected function getProfileDir() diff --git a/src/PHPCR/Shell/Console/Application/EmbeddedApplication.php b/src/PHPCR/Shell/Console/Application/EmbeddedApplication.php index 9b20e06a..01695fcd 100644 --- a/src/PHPCR/Shell/Console/Application/EmbeddedApplication.php +++ b/src/PHPCR/Shell/Console/Application/EmbeddedApplication.php @@ -2,7 +2,8 @@ namespace PHPCR\Shell\Console\Application; -use PHPCR\Shell\Subscriber; +use PHPCR\Shell\DependencyInjection\Container; +use PHPCR\Shell\Console\Helper\PhpcrHelper; /** * Subclass of the full ShellApplication for running as an EmbeddedApplication @@ -12,10 +13,17 @@ */ class EmbeddedApplication extends ShellApplication { - const MODE_SHELL = 'shell'; - const MODE_COMMAND = 'command'; + /** + * @deprecated remove after DoctrinePhpcrBundle is upgraded + */ + const MODE_COMMAND = Container::MODE_EMBEDDED_COMMAND; + + /** + * @deprecated remove after DoctrinePhpcrBundle is upgraded + */ + const MODE_SHELL = Container::MODE_EMBEDDED_SHELL; - protected $mode = self::MODE_SHELL; + protected $mode; /** * The $mode can be one of EmbeddedApplication::MODE_SHELL or EmbeddedApplication::MODE_COMMAND. @@ -27,9 +35,11 @@ class EmbeddedApplication extends ShellApplication */ public function __construct($mode) { - parent::__construct(SessionApplication::APP_NAME, SessionApplication::APP_VERSION); $this->mode = $mode; + $container = new Container($this->mode); + parent::__construct($container, SessionApplication::APP_NAME, SessionApplication::APP_VERSION); $this->setAutoExit(false); + $this->getHelperSet()->set(new PhpcrHelper($container->get('phpcr.session_manager'))); } /** @@ -43,7 +53,7 @@ public function init() $this->registerPhpcrCommands(); - if ($this->mode === self::MODE_SHELL) { + if ($this->container->getMode() === self::MODE_SHELL) { $this->registerShellCommands(); } @@ -55,17 +65,6 @@ public function init() */ protected function getDefaultCommand() { - return 'shell:path:show'; - } - - /** - * {@inheritDoc} - */ - protected function registerEventListeners() - { - $this->dispatcher->addSubscriber(new Subscriber\ProfileFromSessionInputSubscriber()); - $this->dispatcher->addSubscriber(new Subscriber\ExceptionSubscriber()); - $this->dispatcher->addSubscriber(new Subscriber\AliasSubscriber($this->getHelperSet())); - $this->dispatcher->addSubscriber(new Subscriber\AutoSaveSubscriber()); + return $this->mode === self::MODE_SHELL ? 'shell:path:show' : 'list'; } } diff --git a/src/PHPCR/Shell/Console/Application/SessionApplication.php b/src/PHPCR/Shell/Console/Application/SessionApplication.php index a0bb2fa5..5ffedefc 100644 --- a/src/PHPCR/Shell/Console/Application/SessionApplication.php +++ b/src/PHPCR/Shell/Console/Application/SessionApplication.php @@ -6,6 +6,7 @@ use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputInterface; use PHPCR\Shell\Console\Command\ShellCommand; +use PHPCR\Shell\DependencyInjection\Container; /** * This application wraps a single command which accepts @@ -28,7 +29,8 @@ public function __construct() { parent::__construct(self::APP_NAME, self::APP_VERSION); - $this->shellApplication = new ShellApplication(); + $container = new Container(); + $this->shellApplication = new ShellApplication($container); $command = new ShellCommand($this->shellApplication); $command->setApplication($this); diff --git a/src/PHPCR/Shell/Console/Application/Shell.php b/src/PHPCR/Shell/Console/Application/Shell.php index 4636987e..50879e4a 100644 --- a/src/PHPCR/Shell/Console/Application/Shell.php +++ b/src/PHPCR/Shell/Console/Application/Shell.php @@ -103,7 +103,7 @@ private function autocompleter($text) { $info = readline_info(); $text = substr($info['line_buffer'], 0, $info['end']); - $list = $this->application->getHelperSet()->get('phpcr')->getSession()->autocomplete($text); + $list = $this->application->getContainer()->get('phpcr.session')->autocomplete($text); return $list; } diff --git a/src/PHPCR/Shell/Console/Application/ShellApplication.php b/src/PHPCR/Shell/Console/Application/ShellApplication.php index 83416190..b864205d 100644 --- a/src/PHPCR/Shell/Console/Application/ShellApplication.php +++ b/src/PHPCR/Shell/Console/Application/ShellApplication.php @@ -9,28 +9,17 @@ use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; use PHPCR\Shell\Console\Command\Phpcr as CommandPhpcr; use PHPCR\Shell\Console\Command\Shell as CommandShell; -use PHPCR\Shell\Console\Helper\ConfigHelper; -use PHPCR\Shell\Console\Helper\EditorHelper; -use PHPCR\Shell\Console\Helper\NodeHelper; -use PHPCR\Shell\Console\Helper\PathHelper; -use PHPCR\Shell\Console\Helper\RepositoryHelper; -use PHPCR\Shell\Console\Helper\ResultFormatterHelper; -use PHPCR\Shell\Console\Helper\TextHelper; -use PHPCR\Shell\Console\Helper\PhpcrHelper; use PHPCR\Shell\Event; use PHPCR\Shell\Event\ApplicationInitEvent; use PHPCR\Shell\Event\PhpcrShellEvents; -use PHPCR\Shell\Subscriber; use PHPCR\Shell\Console\Command\Phpcr\PhpcrShellCommand; use PHPCR\Shell\Config\Profile; -use PHPCR\Shell\Transport\TransportRegistry; -use PHPCR\Shell\Config\ProfileLoader; -use PHPCR\Shell\Console\Helper\TableHelper; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; /** * Main application for PHPCRSH @@ -52,36 +41,26 @@ class ShellApplication extends Application protected $showUnsupported = false; /** - * Constructor - name and version inherited from SessionApplication - * - * {@inheritDoc} + * @var Symfony\Component\DependencyInjection\ContainerBuilder */ - public function __construct() - { - parent::__construct(SessionApplication::APP_NAME, SessionApplication::APP_VERSION); - $this->profile = new Profile(); - $this->setDispatcher($this->dispatcher = new EventDispatcher()); - $this->transportRegistry = new TransportRegistry(); - $this->registerTransports(); - $this->registerHelpers(); - $this->registerEventListeners(); - } + protected $container; /** - * Initialize the supported transports. + * @var boolean + */ + protected $debug = false; + + /** + * Constructor - name and version inherited from SessionApplication * - * @access private + * {@inheritDoc} */ - protected function registerTransports() + public function __construct($container) { - $transports = array( - new \PHPCR\Shell\Transport\Transport\DoctrineDbal($this->profile), - new \PHPCR\Shell\Transport\Transport\Jackrabbit($this->profile), - ); - - foreach ($transports as $transport) { - $this->transportRegistry->register($transport); - } + parent::__construct(SessionApplication::APP_NAME, SessionApplication::APP_VERSION); + $this->dispatcher = $container->get('event.dispatcher') ? : new EventDispatcher(); + $this->setDispatcher($this->dispatcher); + $this->container = $container; } /** @@ -112,6 +91,7 @@ public function init() } $this->registerPhpcrCommands(); + $this->registerPhpcrStandaloneCommands(); $this->registerShellCommands(); $event = new ApplicationInitEvent($this); @@ -120,31 +100,6 @@ public function init() $this->initialized = true; } - /** - * Register the helpers required by the application - */ - protected function registerHelpers() - { - $phpcrHelper = new PhpcrHelper($this->transportRegistry, $this->profile); - $textHelper = new TextHelper(); - - $helpers = array( - $textHelper, - new ConfigHelper(), - new EditorHelper(), - new NodeHelper(), - new PathHelper(), - new RepositoryHelper($phpcrHelper), - new ResultFormatterHelper($textHelper), - new TableHelper(), - $phpcrHelper - ); - - foreach ($helpers as $helper) { - $this->getHelperSet()->set($helper); - } - } - /** * Register the commands used in the shell */ @@ -157,8 +112,6 @@ protected function registerPhpcrCommands() $this->add(new CommandPhpcr\SessionImpersonateCommand()); $this->add(new CommandPhpcr\SessionImportXMLCommand()); $this->add(new CommandPhpcr\SessionInfoCommand()); - $this->add(new CommandPhpcr\SessionLoginCommand()); - $this->add(new CommandPhpcr\SessionLogoutCommand()); $this->add(new CommandPhpcr\SessionNamespaceListCommand()); $this->add(new CommandPhpcr\SessionNamespaceSetCommand()); $this->add(new CommandPhpcr\NodePropertyRemoveCommand()); @@ -174,16 +127,12 @@ protected function registerPhpcrCommands() $this->add(new CommandPhpcr\RetentionHoldRemoveCommand()); $this->add(new CommandPhpcr\RetentionPolicyGetCommand()); $this->add(new CommandPhpcr\RetentionPolicyRemoveCommand()); - $this->add(new CommandPhpcr\WorkspaceCreateCommand()); - $this->add(new CommandPhpcr\WorkspaceDeleteCommand()); - $this->add(new CommandPhpcr\WorkspaceListCommand()); $this->add(new CommandPhpcr\NodeCloneCommand()); $this->add(new CommandPhpcr\NodeCopyCommand()); $this->add(new CommandPhpcr\NodeEditCommand()); $this->add(new CommandPhpcr\WorkspaceNamespaceListCommand()); $this->add(new CommandPhpcr\WorkspaceNamespaceRegisterCommand()); $this->add(new CommandPhpcr\WorkspaceNamespaceUnregisterCommand()); - $this->add(new CommandPhpcr\WorkspaceUseCommand()); $this->add(new CommandPhpcr\NodeTypeShowCommand()); $this->add(new CommandPhpcr\NodeTypeEditCommand()); $this->add(new CommandPhpcr\NodeTypeUnregisterCommand()); @@ -224,6 +173,16 @@ protected function registerPhpcrCommands() $this->add(new CommandPhpcr\LockUnlockCommand()); } + protected function registerPhpcrStandaloneCommands() + { + $this->add(new CommandPhpcr\SessionLoginCommand()); + $this->add(new CommandPhpcr\SessionLogoutCommand()); + $this->add(new CommandPhpcr\WorkspaceUseCommand()); + $this->add(new CommandPhpcr\WorkspaceCreateCommand()); + $this->add(new CommandPhpcr\WorkspaceDeleteCommand()); + $this->add(new CommandPhpcr\WorkspaceListCommand()); + } + protected function registerShellCommands() { // add shell-specific commands @@ -236,25 +195,6 @@ protected function registerShellCommands() $this->add(new CommandShell\ExitCommand()); } - protected function registerEventListeners() - { - $this->dispatcher->addSubscriber(new Subscriber\ProfileFromSessionInputSubscriber()); - $this->dispatcher->addSubscriber(new Subscriber\ProfileWriterSubscriber( - new ProfileLoader( - $this->getHelperSet()->get('config') - ) - )); - $this->dispatcher->addSubscriber(new Subscriber\ProfileLoaderSubscriber( - new ProfileLoader( - $this->getHelperSet()->get('config') - ) - )); - - $this->dispatcher->addSubscriber(new Subscriber\ConfigInitSubscriber()); - $this->dispatcher->addSubscriber(new Subscriber\ExceptionSubscriber()); - $this->dispatcher->addSubscriber(new Subscriber\AliasSubscriber($this->getHelperSet())); - } - /** * Configure the output formatter */ @@ -308,7 +248,7 @@ public function doRun(InputInterface $input, OutputInterface $output) try { $exitCode = parent::doRun($input, $output); } catch (\Exception $e) { - $this->dispatcher->dispatch(PhpcrShellEvents::COMMAND_EXCEPTION, new Event\CommandExceptionEvent($e, $input, $output)); + $this->dispatcher->dispatch(PhpcrShellEvents::COMMAND_EXCEPTION, new Event\CommandExceptionEvent($e, $this, $output)); return 1; } @@ -342,8 +282,12 @@ public function renderException($exception, $output) */ public function add(Command $command) { + if ($command instanceof ContainerAwareInterface) { + $command->setContainer($this->container); + } + if ($command instanceof PhpcrShellCommand) { - if ($this->showUnsupported || $command->isSupported($this->getHelperSet()->get('repository'))) { + if ($this->showUnsupported || $command->isSupported()) { parent::add($command); } } else { @@ -353,7 +297,29 @@ public function add(Command $command) public function dispatchProfileInitEvent(InputInterface $sessionInput, OutputInterface $output) { - $event = new Event\ProfileInitEvent($this->profile, $sessionInput, $output); + $event = new Event\ProfileInitEvent($this->container->get('config.profile'), $sessionInput, $output); $this->dispatcher->dispatch(PhpcrShellEvents::PROFILE_INIT, $event); } + + public function getContainer() + { + return $this->container; + } + + /** + * Return if the shell is in debug mode + */ + public function isDebug() + { + return $this->debug; + } + + /** + * Debug mode -- more verbose exceptions + */ + public function setDebug($debug) + { + $this->debug = $debug; + } + } diff --git a/src/PHPCR/Shell/Console/Command/BaseCommand.php b/src/PHPCR/Shell/Console/Command/BaseCommand.php new file mode 100644 index 00000000..cdc3c68a --- /dev/null +++ b/src/PHPCR/Shell/Console/Command/BaseCommand.php @@ -0,0 +1,28 @@ +container = $container; + } + + protected function get($serviceId) + { + if (null === $this->container) { + throw new \RuntimeException( + 'Container has not been set on this command' + ); + } + + return $this->container->get($serviceId); + } +} diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/AccessControlPrivilegeListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/AccessControlPrivilegeListCommand.php index 4b364981..07a6ef35 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/AccessControlPrivilegeListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/AccessControlPrivilegeListCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Input\InputOption; use PHPCR\RepositoryInterface; -class AccessControlPrivilegeListCommand extends PhpcrShellCommand +class AccessControlPrivilegeListCommand extends BasePhpcrCommand { protected function configure() { @@ -51,7 +51,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $supported = $input->getOption('supported'); $absOath = $input->getArgument('absPath'); $acm = $session->getAccessControlManager(); @@ -62,7 +62,7 @@ public function execute(InputInterface $input, OutputInterface $output) $privileges = $acm->getPrivileges($absPath); } - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); $table->setHeaders(array('Name')); foreach ($privileges as $privilege) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/PhpcrShellCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/BasePhpcrCommand.php similarity index 80% rename from src/PHPCR/Shell/Console/Command/Phpcr/PhpcrShellCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/BasePhpcrCommand.php index 4c91d502..f7a10dfd 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/PhpcrShellCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/BasePhpcrCommand.php @@ -2,10 +2,15 @@ namespace PHPCR\Shell\Console\Command\Phpcr; -use Symfony\Component\Console\Command\Command; use PHPCR\Shell\Console\Helper\RepositoryHelper; - -class PhpcrShellCommand extends Command +use PHPCR\Shell\Console\Command\BaseCommand; + +/** + * Base command for all PHPCR action commands + * + * @author Daniel Leech + */ +class BasePhpcrCommand extends BaseCommand { protected $descriptorRequires = array(); protected $descriptorDequires = array(); @@ -30,8 +35,9 @@ public function getDescriptorDequires() return $this->descriptorDequires; } - public function isSupported(RepositoryHelper $repositoryHelper) + public function isSupported() { + $repositoryHelper = $this->get('helper.repository'); foreach ($this->descriptorRequires as $key => $value) { $has = $repositoryHelper->hasDescriptor($key, $value); if (!$has) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/LockInfoCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/LockInfoCommand.php index 54d31ae1..cbf143a9 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/LockInfoCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/LockInfoCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class LockInfoCommand extends PhpcrShellCommand +class LockInfoCommand extends BasePhpcrCommand { protected function configure() { @@ -30,7 +30,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $session->getAbsPath($input->getArgument('path')); $workspace = $session->getWorkspace(); $lockManager = $workspace->getLockManager(); @@ -47,7 +47,7 @@ public function execute(InputInterface $input, OutputInterface $output) 'Session scoped?' => $lock->isSessionScoped() ? 'yes' : 'no', ); - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); foreach ($info as $label => $value) { $table->addRow(array($label, $value)); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/LockLockCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/LockLockCommand.php index 0240ce96..203250fc 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/LockLockCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/LockLockCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Input\InputOption; use PHPCR\RepositoryInterface; -class LockLockCommand extends PhpcrShellCommand +class LockLockCommand extends BasePhpcrCommand { protected function configure() { @@ -58,7 +58,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $workspace = $session->getWorkspace(); $lockManager = $workspace->getLockManager(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/LockRefreshCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/LockRefreshCommand.php index 7f262eb7..99ebedf2 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/LockRefreshCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/LockRefreshCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class LockRefreshCommand extends PhpcrShellCommand +class LockRefreshCommand extends BasePhpcrCommand { protected function configure() { @@ -29,7 +29,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $workspace = $session->getWorkspace(); $lockManager = $workspace->getLockManager(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenAddCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenAddCommand.php index 1b840ffe..884a7938 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenAddCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenAddCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class LockTokenAddCommand extends PhpcrShellCommand +class LockTokenAddCommand extends BasePhpcrCommand { protected function configure() { @@ -28,7 +28,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $workspace = $session->getWorkspace(); $lockManager = $workspace->getLockManager(); $lockToken = $input->getArgument('lockToken'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenListCommand.php index 9f8f4a75..a61de960 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenListCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use PHPCR\RepositoryInterface; -class LockTokenListCommand extends PhpcrShellCommand +class LockTokenListCommand extends BasePhpcrCommand { protected function configure() { @@ -27,13 +27,13 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $workspace = $session->getWorkspace(); $lockManager = $workspace->getLockManager(); $lockTokens = $lockManager->getLockTokens(); - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); $table->setHeaders(array('Token')); foreach ($lockTokens as $token) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenRemoveCommand.php index 0971f75f..1d538cfc 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenRemoveCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class LockTokenRemoveCommand extends PhpcrShellCommand +class LockTokenRemoveCommand extends BasePhpcrCommand { protected function configure() { @@ -25,7 +25,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $workspace = $session->getWorkspace(); $lockManager = $workspace->getLockManager(); $lockToken = $input->getArgument('lockToken'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/LockUnlockCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/LockUnlockCommand.php index 125f7751..a2c05c47 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/LockUnlockCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/LockUnlockCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class LockUnlockCommand extends PhpcrShellCommand +class LockUnlockCommand extends BasePhpcrCommand { protected function configure() { @@ -40,7 +40,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $workspace = $session->getWorkspace(); $lockManager = $workspace->getLockManager(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeCloneCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCloneCommand.php index b37d0c99..6c19d911 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeCloneCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCloneCommand.php @@ -2,13 +2,12 @@ namespace PHPCR\Shell\Console\Command\Phpcr; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; -class NodeCloneCommand extends Command +class NodeCloneCommand extends BasePhpcrCommand { protected function configure() { @@ -56,7 +55,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $srcWorkspace = $input->getArgument('srcWorkspace'); $srcAbsPath = $session->getAbsPath($input->getArgument('srcPath')); $destAbsPath = $session->getAbsTargetPath($srcAbsPath, $input->getArgument('destPath')); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeCopyCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCopyCommand.php index 7901f2f3..ffc36879 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeCopyCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCopyCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeCopyCommand extends Command +class NodeCopyCommand extends BasePhpcrCommand { protected function configure() { @@ -86,7 +86,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $srcAbsPath = $session->getAbsPath($input->getArgument('srcPath')); $destAbsPath = $session->getAbsTargetPath($srcAbsPath, $input->getArgument('destPath')); $srcWorkspace = $input->getArgument('srcWorkspace'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeCorrespondingCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCorrespondingCommand.php index 5b4e1d93..abc2996d 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeCorrespondingCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCorrespondingCommand.php @@ -2,12 +2,11 @@ namespace PHPCR\Shell\Console\Command\Phpcr; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeCorrespondingCommand extends Command +class NodeCorrespondingCommand extends BasePhpcrCommand { protected function configure() { @@ -24,7 +23,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $workspaceName = $input->getArgument('workspaceName'); $currentNode = $session->getNodeByPathOrIdentifier($path); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeCreateCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCreateCommand.php index 494c75ca..a8fdb584 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeCreateCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCreateCommand.php @@ -2,12 +2,11 @@ namespace PHPCR\Shell\Console\Command\Phpcr; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeCreateCommand extends Command +class NodeCreateCommand extends BasePhpcrCommand { protected function configure() { @@ -40,8 +39,8 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); - $pathHelper = $this->getHelper('path'); + $session = $this->get('phpcr.session'); + $pathHelper = $this->get('helper.path'); $path = $session->getAbsPath($input->getArgument('path')); $primaryNodeTypeName = $input->getArgument('primaryNodeTypeName'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeDefinitionCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeDefinitionCommand.php index f6265c4d..b9b6f63c 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeDefinitionCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeDefinitionCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\Util\CND\Writer\CndWriter; -class NodeDefinitionCommand extends PhpcrShellCommand +class NodeDefinitionCommand extends BasePhpcrCommand { protected function configure() { @@ -24,7 +24,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $currentNode = $session->getNodeByPathOrIdentifier($path); $workspace = $session->getWorkspace(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeEditCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeEditCommand.php index a435060e..d365470f 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeEditCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeEditCommand.php @@ -2,14 +2,9 @@ namespace PHPCR\Shell\Console\Command\Phpcr; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -use PHPCR\ImportUUIDBehaviorInterface; -use PHPCR\Shell\Console\Helper\PathHelper; -use Symfony\Component\Serializer\Encoder\XmlEncoder; -use Symfony\Component\Serializer\Encoder\JsonEncoder; use PHPCR\Shell\Serializer\NodeNormalizer; use Symfony\Component\Serializer\Serializer; use PHPCR\Shell\Serializer\YamlEncoder; @@ -17,7 +12,7 @@ use PHPCR\PathNotFoundException; use PHPCR\Util\UUIDHelper; -class NodeEditCommand extends Command +class NodeEditCommand extends BasePhpcrCommand { protected function configure() { @@ -40,7 +35,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); if (UUIDHelper::isUUID($path)) { @@ -49,8 +44,8 @@ public function execute(InputInterface $input, OutputInterface $output) } else { $path = $session->getAbsPath($path); // Otherwise it is a path which may or may not exist - $parentPath = $this->getHelper('path')->getParentPath($path); - $nodeName = $this->getHelper('path')->getNodeName($path); + $parentPath = $this->get('helper.path')->getParentPath($path); + $nodeName = $this->get('helper.path')->getNodeName($path); $type = $input->getOption('type'); try { @@ -63,8 +58,8 @@ public function execute(InputInterface $input, OutputInterface $output) } } - $editor = $this->getHelper('editor'); - $dialog = $this->getHelper('dialog'); + $editor = $this->get('helper.editor'); + $dialog = $this->get('helper.question'); $skipBinary = true; $noRecurse = true; @@ -84,7 +79,7 @@ public function execute(InputInterface $input, OutputInterface $output) $message = ''; if ($error) { $template = <<session = $this->getHelper('phpcr')->getSession(); + $this->session = $this->get('phpcr.session'); $filePath = $input->getArgument('file'); $force = $input->getOption('force'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php index d8860908..2400e4e3 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php @@ -2,12 +2,11 @@ namespace PHPCR\Shell\Console\Command\Phpcr; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeInfoCommand extends Command +class NodeInfoCommand extends BasePhpcrCommand { protected function configure() { @@ -22,11 +21,11 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); - $nodeHelper = $this->getHelper('node'); + $nodeHelper = $this->get('helper.node'); $currentNode = $session->getNodeByPathOrIdentifier($path); - $formatter = $this->getHelper('result_formatter'); + $formatter = $this->get('helper.result_formatter'); $mixins = $currentNode->getMixinNodeTypes(); $mixinNodeTypeNames = array(); @@ -61,7 +60,7 @@ public function execute(InputInterface $input, OutputInterface $output) 'Locked?' => $isLocked, ); - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); foreach ($info as $label => $value) { $table->addRow(array($label, $value)); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleFollowCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleFollowCommand.php index 158567f0..81a9c6f7 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleFollowCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleFollowCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class NodeLifecycleFollowCommand extends PhpcrShellCommand +class NodeLifecycleFollowCommand extends BasePhpcrCommand { protected function configure() { @@ -34,7 +34,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $currentNode = $session->getNodeByPathOrIdentifier($path); $transition = $input->getArgument('transition'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleListCommand.php index d9371127..3ed6aae1 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleListCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class NodeLifecycleListCommand extends PhpcrShellCommand +class NodeLifecycleListCommand extends BasePhpcrCommand { protected function configure() { @@ -25,7 +25,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $currentNode = $session->getNodeByPathOrIdentifier($path); $transitions = $currentNode->getAllowedLifecycleTransitions(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php index 04caaf0e..c8ae510d 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php @@ -12,7 +12,7 @@ use PHPCR\PropertyInterface; use PHPCR\NodeInterface; -class NodeListCommand extends Command +class NodeListCommand extends BasePhpcrCommand { protected $formatter; protected $filters; @@ -47,8 +47,8 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $this->formatter = $this->getHelper('result_formatter'); - $this->textHelper = $this->getHelper('text'); + $this->formatter = $this->get('helper.result_formatter'); + $this->textHelper = $this->get('helper.text'); $this->filters = $input->getOption('filter'); $this->maxLevel = $input->getOption('level'); @@ -56,7 +56,7 @@ public function execute(InputInterface $input, OutputInterface $output) $this->showProperties = $input->getOption('properties'); $this->showTemplate = $input->getOption('template'); - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $currentNode = $session->getNodeByPathOrIdentifier($path); @@ -66,7 +66,7 @@ public function execute(InputInterface $input, OutputInterface $output) $this->showProperties = true; } - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); $this->renderNode($currentNode, $table); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinAddCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinAddCommand.php index bcd2ccf3..281d62d0 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinAddCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinAddCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeMixinAddCommand extends Command +class NodeMixinAddCommand extends BasePhpcrCommand { protected function configure() { @@ -43,7 +43,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $mixinName = $input->getArgument('mixinName'); $currentNode = $session->getNodeByPathOrIdentifier($path); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinRemoveCommand.php index 4eee4a19..9aee5da6 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinRemoveCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeMixinRemoveCommand extends Command +class NodeMixinRemoveCommand extends BasePhpcrCommand { protected function configure() { @@ -27,7 +27,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $mixinName = $input->getArgument('mixinName'); $path = $input->getArgument('path'); $currentNode = $session->getNodeByPathOrIdentifier($path); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeMoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeMoveCommand.php index 7c3d4b2a..a6b916b2 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeMoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeMoveCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeMoveCommand extends Command +class NodeMoveCommand extends BasePhpcrCommand { protected function configure() { @@ -51,7 +51,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $srcPath = $input->getArgument('srcPath'); $destPath = $input->getArgument('destPath'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeOrderBeforeCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeOrderBeforeCommand.php index 62649fb3..8483ce4f 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeOrderBeforeCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeOrderBeforeCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeOrderBeforeCommand extends Command +class NodeOrderBeforeCommand extends BasePhpcrCommand { protected function configure() { @@ -39,7 +39,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $srcChildRelPath = $input->getArgument('srcChildRelPath'); $destChildRelPath = $input->getArgument('destChildRelPath'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyRemoveCommand.php index 279d2a73..2b67060f 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyRemoveCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\PathNotFoundException; -class NodePropertyRemoveCommand extends Command +class NodePropertyRemoveCommand extends BasePhpcrCommand { protected function configure() { @@ -23,7 +23,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $absPath = $input->getArgument('absPath'); try { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertySetCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertySetCommand.php index 544cc984..7c690f9e 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertySetCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertySetCommand.php @@ -10,7 +10,7 @@ use PHPCR\PropertyType; use PHPCR\PathNotFoundException; -class NodePropertySetCommand extends Command +class NodePropertySetCommand extends BasePhpcrCommand { protected function configure() { @@ -61,8 +61,8 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); - $pathHelper = $this->getHelper('path'); + $session = $this->get('phpcr.session'); + $pathHelper = $this->get('helper.path'); $path = $session->getAbsPath($input->getArgument('path')); $value = $input->getArgument('value'); $type = $input->getOption('type'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyShowCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyShowCommand.php index 87e26cdb..c0c174bd 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyShowCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyShowCommand.php @@ -9,7 +9,7 @@ use PHPCR\PathNotFoundException; use PHPCR\PropertyInterface; -class NodePropertyShowCommand extends Command +class NodePropertyShowCommand extends BasePhpcrCommand { protected function configure() { @@ -24,9 +24,9 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $absPath = $session->getAbsPath($input->getArgument('absPath')); - $resultFormatHelper = $this->getHelper('result_formatter'); + $resultFormatHelper = $this->get('helper.result_formatter'); try { $property = $session->getItem($absPath); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php index 9830e914..006a48fb 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeReferencesCommand extends Command +class NodeReferencesCommand extends BasePhpcrCommand { protected function configure() { @@ -39,7 +39,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $currentNode = $session->getNodeByPathOrIdentifier($path); $name = $input->getArgument('name'); @@ -52,7 +52,7 @@ public function execute(InputInterface $input, OutputInterface $output) $references['weak'] = $currentNode->getWeakReferences($name ? : null); $references['strong'] = $currentNode->getReferences($name ? : null); - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); $table->setHeaders(array( 'Type', 'Property', 'Node Path' )); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeRemoveCommand.php index 25e6ac19..745ec638 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeRemoveCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeRemoveCommand extends Command +class NodeRemoveCommand extends BasePhpcrCommand { protected function configure() { @@ -22,7 +22,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $targetPath = $input->getArgument('path'); $currentPath = $session->getCwd(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeRenameCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeRenameCommand.php index 3628b283..03db1ded 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeRenameCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeRenameCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeRenameCommand extends Command +class NodeRenameCommand extends BasePhpcrCommand { protected function configure() { @@ -56,7 +56,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $newName = $input->getArgument('newName'); $currentNode = $session->getNodeByPathOrIdentifier($path); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeSetPrimaryTypeCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeSetPrimaryTypeCommand.php index 1eb1c222..27bff944 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeSetPrimaryTypeCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeSetPrimaryTypeCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeSetPrimaryTypeCommand extends Command +class NodeSetPrimaryTypeCommand extends BasePhpcrCommand { protected function configure() { @@ -30,7 +30,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $nodeTypeName = $input->getArgument('nodeTypeName'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedRemoveCommand.php index e7add2a6..a861969f 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedRemoveCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class NodeSharedRemoveCommand extends PhpcrShellCommand +class NodeSharedRemoveCommand extends BasePhpcrCommand { protected function configure() { @@ -31,7 +31,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $currentNode = $session->getNodeByPathOrIdentifier($path); $sharedSet = $currentNode->removeSharedSet(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedShowCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedShowCommand.php index db4e9874..018917a4 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedShowCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedShowCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class NodeSharedShowCommand extends PhpcrShellCommand +class NodeSharedShowCommand extends BasePhpcrCommand { protected function configure() { @@ -30,7 +30,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $currentNode = $session->getNodeByPathOrIdentifier($path); $sharedSet = $currentNode->getSharedSet(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTreeCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTreeCommand.php index 1281e5a6..51587713 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTreeCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTreeCommand.php @@ -32,9 +32,9 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $this->formatter = $this->getHelper('result_formatter'); - $this->textHelper = $this->getHelper('text'); - $this->session = $this->getHelper('phpcr')->getSession(); + $this->formatter = $this->get('helper.result_formatter'); + $this->textHelper = $this->get('helper.text'); + $this->session = $this->get('phpcr.session'); $this->filters = $input->getOption('filter'); $this->level = $input->getOption('level'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeEditCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeEditCommand.php index ee6a8616..14d2d239 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeEditCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeEditCommand.php @@ -10,7 +10,7 @@ use PHPCR\NodeType\NoSuchNodeTypeException; use PHPCR\Util\CND\Parser\CndParser; -class NodeTypeEditCommand extends Command +class NodeTypeEditCommand extends BasePhpcrCommand { protected function configure() { @@ -32,9 +32,9 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); - $editor = $this->getHelper('editor'); - $dialog = $this->getHelper('dialog'); + $session = $this->get('phpcr.session'); + $editor = $this->get('helper.editor'); + $dialog = $this->get('helper.question'); $nodeTypeName = $input->getArgument('nodeTypeName'); $workspace = $session->getWorkspace(); $namespaceRegistry = $workspace->getNamespaceRegistry(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeListCommand.php index b4773b4b..00a554ed 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeListCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeTypeListCommand extends Command +class NodeTypeListCommand extends BasePhpcrCommand { protected function configure() { @@ -22,7 +22,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $workspace = $session->getWorkspace(); $namespaceRegistry = $workspace->getNamespaceRegistry(); $nodeTypeManager = $workspace->getNodeTypeManager(); @@ -30,7 +30,7 @@ public function execute(InputInterface $input, OutputInterface $output) $nodeTypes = $nodeTypeManager->getAllNodeTypes(); - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); $table->setHeaders(array('Name', 'Primary Item Name', 'Abstract?', 'Mixin?', 'Queryable?')); foreach ($nodeTypes as $nodeType) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeLoadCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeLoadCommand.php index 5ea3d711..f50269df 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeLoadCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeLoadCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; -class NodeTypeLoadCommand extends Command +class NodeTypeLoadCommand extends BasePhpcrCommand { protected function configure() { @@ -32,7 +32,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $cndFile = $input->getArgument('cndFile'); $update = $input->getOption('update'); $workspace = $session->getWorkspace(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeShowCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeShowCommand.php index fa52e173..e4cdb21e 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeShowCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeShowCommand.php @@ -9,7 +9,7 @@ use PHPCR\Util\CND\Writer\CndWriter; use PHPCR\NodeType\NoSuchNodeTypeException; -class NodeTypeShowCommand extends Command +class NodeTypeShowCommand extends BasePhpcrCommand { protected function configure() { @@ -24,7 +24,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $nodeTypeName = $input->getArgument('nodeTypeName'); $workspace = $session->getWorkspace(); $namespaceRegistry = $workspace->getNamespaceRegistry(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeUnregisterCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeUnregisterCommand.php index f3745724..984543b9 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeUnregisterCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeUnregisterCommand.php @@ -6,7 +6,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeTypeUnregisterCommand extends PhpcrShellCommand +class NodeTypeUnregisterCommand extends BasePhpcrCommand { protected function configure() { @@ -23,7 +23,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $nodeTypeName = $input->getArgument('nodeTypeName'); $workspace = $session->getWorkspace(); $namespaceRegistry = $workspace->getNamespaceRegistry(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeUpdateCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeUpdateCommand.php index ca84f609..49927063 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeUpdateCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeUpdateCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class NodeUpdateCommand extends Command +class NodeUpdateCommand extends BasePhpcrCommand { protected function configure() { @@ -36,7 +36,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); $srcWorkspace = $input->getArgument('srcWorkspace'); $currentNode = $session->getNodeByPathOrIdentifier($path); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/QueryCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/QueryCommand.php index bedb576c..0a635d15 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/QueryCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/QueryCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class QueryCommand extends Command +class QueryCommand extends BasePhpcrCommand { protected function configure() { @@ -34,7 +34,7 @@ public function execute(InputInterface $input, OutputInterface $output) $offset = $input->getOption('offset'); $query = $input->getArgument('query'); - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $workspace = $session->getWorkspace();; $supportedQueryLanguages = $workspace->getQueryManager()->getSupportedQueryLanguages(); @@ -61,6 +61,6 @@ public function execute(InputInterface $input, OutputInterface $output) $result = $query->execute(); $elapsed = microtime(true) - $start; - $this->getHelper('result_formatter')->formatQueryResult($result, $output, $elapsed); + $this->get('helper.result_formatter')->formatQueryResult($result, $output, $elapsed); } } diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/QueryDeleteCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/QueryDeleteCommand.php index 3ac9e5f9..c00d4ef1 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/QueryDeleteCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/QueryDeleteCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use PHPCR\Util\QOM\Sql2ToQomQueryConverter; -class QueryDeleteCommand extends Command +class QueryDeleteCommand extends BasePhpcrCommand { protected function configure() { @@ -36,7 +36,7 @@ public function execute(InputInterface $input, OutputInterface $output) $sql = substr($sql, 0, -1); } - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $qm = $session->getWorkspace()->getQueryManager(); if (!preg_match('{^delete from}', strtolower($sql))) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/QuerySelectCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/QuerySelectCommand.php index 965bb4b6..1ebb252e 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/QuerySelectCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/QuerySelectCommand.php @@ -6,7 +6,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class QuerySelectCommand extends Command +class QuerySelectCommand extends BasePhpcrCommand { protected function configure() { @@ -32,7 +32,7 @@ public function execute(InputInterface $input, OutputInterface $output) $sql = substr($sql, 0, -1); } - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $qm = $session->getWorkspace()->getQueryManager(); $query = $qm->createQuery($sql, 'JCR-SQL2'); @@ -41,6 +41,6 @@ public function execute(InputInterface $input, OutputInterface $output) $result = $query->execute(); $elapsed = microtime(true) - $start; - $this->getHelper('result_formatter')->formatQueryResult($result, $output, $elapsed); + $this->get('helper.result_formatter')->formatQueryResult($result, $output, $elapsed); } } diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/QueryUpdateCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/QueryUpdateCommand.php index ed6e721b..ca6e85c6 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/QueryUpdateCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/QueryUpdateCommand.php @@ -6,13 +6,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use PHPCR\Shell\Query\UpdateParser; -use Jackalope\Query\QOM\ComparisonConstraint; -use Jackalope\Query\QOM\PropertyValue; -use PHPCR\Query\QOM\QueryObjectModelConstantsInterface; -use PHPCR\Query\QOM\LiteralInterface; use PHPCR\Shell\Query\UpdateProcessor; -class QueryUpdateCommand extends Command +class QueryUpdateCommand extends BasePhpcrCommand { /** * @var OutputInterface @@ -30,7 +26,7 @@ protected function configure() UPDATE [nt:unstructured] AS a SET title = 'foobar' WHERE a.title = 'barfoo'; You can also manipulate multivalue fields: - + # Delete index @@ -45,7 +41,7 @@ protected function configure() # Replace the multivalue value "Planes" with "Trains" UPDATE [nt:unstructured] AS a SET a.tags[] = array_replace(a.tags, 'Planes', 'Trains') - # Append a multivalue + # Append a multivalue UPDATE [nt:unstructured] AS a SET a.tags = array_append(a.tags, 'Rockets') # Remove by value @@ -71,7 +67,7 @@ public function execute(InputInterface $input, OutputInterface $output) $sql = substr($sql, 0, -1); } - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $qm = $session->getWorkspace()->getQueryManager(); $updateParser = new UpdateParser($qm->getQOMFactory()); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/RepositoryDescriptorListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/RepositoryDescriptorListCommand.php index da726c37..dc9e8d2e 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/RepositoryDescriptorListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/RepositoryDescriptorListCommand.php @@ -6,7 +6,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class RepositoryDescriptorListCommand extends Command +class RepositoryDescriptorListCommand extends BasePhpcrCommand { protected function configure() { @@ -21,11 +21,11 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $repository = $session->getRepository(); $keys = $repository->getDescriptorKeys(); - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); $table->setHeaders(array('Key', 'Value', 'Standard?')); foreach ($keys as $key) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldAddCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldAddCommand.php index fe000035..cd2a0719 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldAddCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldAddCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Input\InputOption; use PHPCR\RepositoryInterface; -class RetentionHoldAddCommand extends PhpcrShellCommand +class RetentionHoldAddCommand extends BasePhpcrCommand { protected function configure() { @@ -33,7 +33,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $retentionManager = $session->getRetentionManager(); $absPath = $input->getArgument('absPath'); $isDeep = $input->getOption('is-deep'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldListCommand.php index a8e5e602..08a8d05e 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldListCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class RetentionHoldListCommand extends PhpcrShellCommand +class RetentionHoldListCommand extends BasePhpcrCommand { protected function configure() { @@ -26,12 +26,12 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $retentionManager = $session->getRetentionManager(); $absPath = $input->getArgument('absPath'); $holds = $retentionManager->getHolds($absPath); - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); $table->setHeaders(array('Name')); foreach ($holds as $hold) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldRemoveCommand.php index 3e8073e8..b1205dbc 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldRemoveCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class RetentionHoldRemoveCommand extends PhpcrShellCommand +class RetentionHoldRemoveCommand extends BasePhpcrCommand { protected function configure() { @@ -28,7 +28,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $retentionManager = $session->getRetentionManager(); $absPath = $input->getArgument('absPath'); $name = $input->getArgument('name'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/RetentionPolicyGetCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/RetentionPolicyGetCommand.php index aecef1b6..a1626510 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/RetentionPolicyGetCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/RetentionPolicyGetCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class RetentionPolicyGetCommand extends PhpcrShellCommand +class RetentionPolicyGetCommand extends BasePhpcrCommand { protected function configure() { @@ -25,7 +25,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $retentionManager = $session->getRetentionManager(); $absPath = $input->getArgument('absPath'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/RetentionPolicyRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/RetentionPolicyRemoveCommand.php index e16c93cd..d34d8439 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/RetentionPolicyRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/RetentionPolicyRemoveCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; -class RetentionPolicyRemoveCommand extends PhpcrShellCommand +class RetentionPolicyRemoveCommand extends BasePhpcrCommand { protected function configure() { @@ -25,7 +25,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $retentionManager = $session->getRetentionManager(); $absPath = $input->removeArgument('absPath'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/SessionExportViewCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/SessionExportViewCommand.php index 8019beed..8dde81bb 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/SessionExportViewCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/SessionExportViewCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Input\InputOption; use PHPCR\Util\PathHelper; -class SessionExportViewCommand extends Command +class SessionExportViewCommand extends BasePhpcrCommand { protected function configure() { @@ -57,11 +57,11 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $file = $input->getArgument('file'); $pretty = $input->getOption('pretty'); $exportDocument = $input->getOption('document'); - $dialog = $this->getHelper('dialog'); + $dialog = $this->get('helper.question'); if (file_exists($file)) { $confirmed = true; diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/SessionImpersonateCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/SessionImpersonateCommand.php index cdfa01a9..d6352789 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/SessionImpersonateCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/SessionImpersonateCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use PHPCR\SimpleCredentials; -class SessionImpersonateCommand extends PhpcrShellCommand +class SessionImpersonateCommand extends BasePhpcrCommand { protected function configure() { @@ -41,7 +41,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $username = $input->getArgument('username'); $credentials = new SimpleCredentials($username, ''); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/SessionImportXMLCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/SessionImportXMLCommand.php index 78f95c3d..d35bf658 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/SessionImportXMLCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/SessionImportXMLCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Input\InputOption; use PHPCR\Util\PathHelper; -class SessionImportXMLCommand extends Command +class SessionImportXMLCommand extends BasePhpcrCommand { protected $uuidBehaviors = array( 'create-new', @@ -90,7 +90,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $file = $input->getArgument('file'); $parentAbsPath = $input->getArgument('parentAbsPath'); $uuidBehavior = $input->getOption('uuid-behavior'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/SessionInfoCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/SessionInfoCommand.php index c296867d..b805254b 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/SessionInfoCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/SessionInfoCommand.php @@ -6,7 +6,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class SessionInfoCommand extends Command +class SessionInfoCommand extends BasePhpcrCommand { protected function configure() { @@ -20,7 +20,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $repository = $session->getRepository(); $info = array( @@ -36,7 +36,7 @@ public function execute(InputInterface $input, OutputInterface $output) $attribute = $session->getAttribute($attributeName); } - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); $table->setHeaders(array('Key', 'Value')); foreach ($info as $key => $value) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/SessionLoginCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/SessionLoginCommand.php index 0f06e501..fafda620 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/SessionLoginCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/SessionLoginCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class SessionLoginCommand extends Command +class SessionLoginCommand extends BasePhpcrCommand { protected function configure() { @@ -26,6 +26,6 @@ public function execute(InputInterface $input, OutputInterface $output) $username = $input->getArgument('userId'); $password = $input->getArgument('password'); $workspaceName = $input->getArgument('workspaceName'); - $this->getHelper('phpcr')->relogin($username, $password, $workspaceName); + $this->get('phpcr.session_manager')->relogin($username, $password, $workspaceName); } } diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/SessionLogoutCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/SessionLogoutCommand.php index 3da52dd9..7a3cb514 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/SessionLogoutCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/SessionLogoutCommand.php @@ -6,7 +6,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class SessionLogoutCommand extends Command +class SessionLogoutCommand extends BasePhpcrCommand { protected function configure() { @@ -22,7 +22,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $session->logout(); } } diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceListCommand.php index 6436354f..e88675cf 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceListCommand.php @@ -6,7 +6,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class SessionNamespaceListCommand extends Command +class SessionNamespaceListCommand extends BasePhpcrCommand { protected function configure() { @@ -20,10 +20,10 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $prefixes = $session->getNamespacePrefixes(); - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); $table->setHeaders(array('Prefix', 'URI')); foreach ($prefixes as $prefix) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceSetCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceSetCommand.php index b53b0232..8b2c4733 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceSetCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceSetCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class SessionNamespaceSetCommand extends Command +class SessionNamespaceSetCommand extends BasePhpcrCommand { protected function configure() { @@ -30,7 +30,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $prefix = $input->getArgument('prefix'); $uri = $input->getArgument('uri'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/SessionRefreshCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/SessionRefreshCommand.php index b57b4a7a..f15ce4a0 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/SessionRefreshCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/SessionRefreshCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputOption; -class SessionRefreshCommand extends Command +class SessionRefreshCommand extends BasePhpcrCommand { protected function configure() { @@ -33,7 +33,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $keepChanges = $input->getOption('keep-changes'); $session->refresh($keepChanges); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/SessionSaveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/SessionSaveCommand.php index a517483e..73dfc2c6 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/SessionSaveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/SessionSaveCommand.php @@ -6,7 +6,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class SessionSaveCommand extends Command +class SessionSaveCommand extends BasePhpcrCommand { protected function configure() { @@ -33,7 +33,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $session->save(); } diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckinCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckinCommand.php index 8fa4ef85..d555ceff 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckinCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckinCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class VersionCheckinCommand extends Command +class VersionCheckinCommand extends BasePhpcrCommand { protected function configure() { @@ -47,8 +47,8 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); - $nodeHelper = $this->getHelper('node'); + $session = $this->get('phpcr.session'); + $nodeHelper = $this->get('helper.node'); $path = $input->getArgument('path'); $workspace = $session->getWorkspace(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckoutCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckoutCommand.php index 050d315b..77082e79 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckoutCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckoutCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class VersionCheckoutCommand extends Command +class VersionCheckoutCommand extends BasePhpcrCommand { protected function configure() { @@ -35,8 +35,8 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); - $nodeHelper = $this->getHelper('node'); + $session = $this->get('phpcr.session'); + $nodeHelper = $this->get('helper.node'); $absPath = $input->getArgument('path'); $workspace = $session->getWorkspace(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckpointCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckpointCommand.php index 09123263..c4c60477 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckpointCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckpointCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class VersionCheckpointCommand extends Command +class VersionCheckpointCommand extends BasePhpcrCommand { protected function configure() { @@ -25,8 +25,8 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); - $nodeHelper = $this->getHelper('node'); + $session = $this->get('phpcr.session'); + $nodeHelper = $this->get('helper.node'); $path = $input->getArgument('path'); $workspace = $session->getWorkspace(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php index 6622a06e..5be47311 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class VersionHistoryCommand extends Command +class VersionHistoryCommand extends BasePhpcrCommand { protected function configure() { @@ -22,9 +22,9 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); - $nodeHelper = $this->getHelper('node'); - $table = $this->getHelper('table')->create(); + $session = $this->get('phpcr.session'); + $nodeHelper = $this->get('helper.node'); + $table = $this->get('helper.table')->create(); $path = $input->getArgument('path'); $workspace = $session->getWorkspace(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/VersionRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/VersionRemoveCommand.php index 43240ba4..c6e39cca 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/VersionRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/VersionRemoveCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class VersionRemoveCommand extends Command +class VersionRemoveCommand extends BasePhpcrCommand { protected function configure() { @@ -37,7 +37,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $versionName = $input->getArgument('versionName'); $path = $session->getAbsPath($input->getArgument('path')); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/VersionRestoreCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/VersionRestoreCommand.php index 9d319f8f..1d8dfd30 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/VersionRestoreCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/VersionRestoreCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; -class VersionRestoreCommand extends Command +class VersionRestoreCommand extends BasePhpcrCommand { protected function configure() { @@ -93,7 +93,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $session->getAbsPath($input->getArgument('path')); $versionName = $input->getArgument('versionName'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceCreateCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceCreateCommand.php index d04a5e4f..594fd2ee 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceCreateCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceCreateCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class WorkspaceCreateCommand extends Command +class WorkspaceCreateCommand extends BasePhpcrCommand { protected function configure() { @@ -30,7 +30,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $name = $input->getArgument('name'); $srcWorkspace = $input->getArgument('srcWorkspace'); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceDeleteCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceDeleteCommand.php index bdf26353..7f4416b0 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceDeleteCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceDeleteCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class WorkspaceDeleteCommand extends Command +class WorkspaceDeleteCommand extends BasePhpcrCommand { protected function configure() { @@ -24,7 +24,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $name = $input->getArgument('name'); $workspace = $session->getWorkspace(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceListCommand.php index b1290e0f..69b5a0c7 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceListCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class WorkspaceListCommand extends Command +class WorkspaceListCommand extends BasePhpcrCommand { protected function configure() { @@ -31,12 +31,12 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $workspace = $session->getWorkspace(); $availableWorkspaces = $workspace->getAccessibleWorkspaceNames(); - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); $table->setHeaders(array('Name')); foreach ($availableWorkspaces as $availableWorkspace) { if ($availableWorkspace == $workspace->getName()) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceListCommand.php index 9dad6836..4f2fa9e1 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceListCommand.php @@ -6,7 +6,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class WorkspaceNamespaceListCommand extends Command +class WorkspaceNamespaceListCommand extends BasePhpcrCommand { protected function configure() { @@ -20,13 +20,13 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $workspace = $session->getWorkspace(); $namespaceRegistry = $workspace->getNamespaceRegistry(); $prefixes = $namespaceRegistry->getPrefixes(); - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); $table->setHeaders(array('Prefix', 'URI')); foreach ($prefixes as $prefix) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceRegisterCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceRegisterCommand.php index e107cf4d..59672183 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceRegisterCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceRegisterCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class WorkspaceNamespaceRegisterCommand extends Command +class WorkspaceNamespaceRegisterCommand extends BasePhpcrCommand { protected function configure() { @@ -23,7 +23,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $workspace = $session->getWorkspace(); $namespaceRegistry = $workspace->getNamespaceRegistry(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceUnregisterCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceUnregisterCommand.php index 28fea8a7..4797832d 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceUnregisterCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceUnregisterCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class WorkspaceNamespaceUnregisterCommand extends Command +class WorkspaceNamespaceUnregisterCommand extends BasePhpcrCommand { protected function configure() { @@ -32,7 +32,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $workspace = $session->getWorkspace(); $namespaceRegistry = $workspace->getNamespaceRegistry(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceUseCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceUseCommand.php index 875baac4..4f493642 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceUseCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceUseCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -class WorkspaceUseCommand extends Command +class WorkspaceUseCommand extends BasePhpcrCommand { protected function configure() { @@ -24,6 +24,6 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { $workspaceName = $input->getArgument('name'); - $this->getHelper('phpcr')->changeWorkspace($workspaceName); + $this->get('phpcr.session_manager')->changeWorkspace($workspaceName); } } diff --git a/src/PHPCR/Shell/Console/Command/Shell/AliasListCommand.php b/src/PHPCR/Shell/Console/Command/Shell/AliasListCommand.php index 5e4453dd..e693bf6b 100644 --- a/src/PHPCR/Shell/Console/Command/Shell/AliasListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Shell/AliasListCommand.php @@ -2,11 +2,11 @@ namespace PHPCR\Shell\Console\Command\Shell; -use Symfony\Component\Console\Command\Command; +use PHPCR\Shell\Console\Command\BaseCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class AliasListCommand extends Command +class AliasListCommand extends BaseCommand { public function configure() { @@ -20,10 +20,10 @@ public function configure() public function execute(InputInterface $input, OutputInterface $output) { - $config = $this->getHelper('config'); + $config = $this->get('config.manager'); $aliases = $config->getConfig('alias'); - $table = $this->getHelper('table')->create(); + $table = $this->get('helper.table')->create(); $table->setHeaders(array('Alias', 'Command')); foreach ($aliases as $alias => $command) { diff --git a/src/PHPCR/Shell/Console/Command/Shell/ClearCommand.php b/src/PHPCR/Shell/Console/Command/Shell/ClearCommand.php index 74d85cc0..98a65b5a 100644 --- a/src/PHPCR/Shell/Console/Command/Shell/ClearCommand.php +++ b/src/PHPCR/Shell/Console/Command/Shell/ClearCommand.php @@ -2,11 +2,11 @@ namespace PHPCR\Shell\Console\Command\Shell; -use Symfony\Component\Console\Command\Command; +use PHPCR\Shell\Console\Command\BaseCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class ClearCommand extends Command +class ClearCommand extends BaseCommand { public function configure() { @@ -23,4 +23,3 @@ public function execute(InputInterface $input, OutputInterface $output) $output->write("\033[2J\033[;H"); } } - diff --git a/src/PHPCR/Shell/Console/Command/Shell/ConfigInitCommand.php b/src/PHPCR/Shell/Console/Command/Shell/ConfigInitCommand.php index 821b79a4..3ccf9a03 100644 --- a/src/PHPCR/Shell/Console/Command/Shell/ConfigInitCommand.php +++ b/src/PHPCR/Shell/Console/Command/Shell/ConfigInitCommand.php @@ -2,11 +2,11 @@ namespace PHPCR\Shell\Console\Command\Shell; -use Symfony\Component\Console\Command\Command; +use PHPCR\Shell\Console\Command\BaseCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class ConfigInitCommand extends Command +class ConfigInitCommand extends BaseCommand { protected $output; @@ -23,7 +23,7 @@ public function configure() public function execute(InputInterface $input, OutputInterface $output) { $this->output = $output; - $configHelper = $this->getHelper('config'); - $configHelper->initConfig($output, $this->getHelper('dialog'), $input->getOption('no-interaction')); + $configHelper = $this->get('config.manager'); + $configHelper->initConfig($output, $this->get('helper.question'), $input->getOption('no-interaction')); } } diff --git a/src/PHPCR/Shell/Console/Command/Shell/ConfigReloadCommand.php b/src/PHPCR/Shell/Console/Command/Shell/ConfigReloadCommand.php index 3c4c2236..0a77bde6 100644 --- a/src/PHPCR/Shell/Console/Command/Shell/ConfigReloadCommand.php +++ b/src/PHPCR/Shell/Console/Command/Shell/ConfigReloadCommand.php @@ -2,11 +2,11 @@ namespace PHPCR\Shell\Console\Command\Shell; -use Symfony\Component\Console\Command\Command; +use PHPCR\Shell\Console\Command\BaseCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class ConfigReloadCommand extends Command +class ConfigReloadCommand extends BaseCommand { protected $output; @@ -23,7 +23,7 @@ public function configure() public function execute(InputInterface $input, OutputInterface $output) { $this->output = $output; - $config = $this->getHelper('config'); + $config = $this->get('config.manager'); $config->loadConfig(); } } diff --git a/src/PHPCR/Shell/Console/Command/Shell/ExitCommand.php b/src/PHPCR/Shell/Console/Command/Shell/ExitCommand.php index 492c8458..b23d4e92 100644 --- a/src/PHPCR/Shell/Console/Command/Shell/ExitCommand.php +++ b/src/PHPCR/Shell/Console/Command/Shell/ExitCommand.php @@ -2,11 +2,11 @@ namespace PHPCR\Shell\Console\Command\Shell; -use Symfony\Component\Console\Command\Command; +use PHPCR\Shell\Console\Command\BaseCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class ExitCommand extends Command +class ExitCommand extends BaseCommand { public function configure() { @@ -16,8 +16,8 @@ public function configure() public function execute(InputInterface $input, OutputInterface $output) { - $dialog = $this->getHelper('dialog'); - $session = $this->getHelper('phpcr')->getSession(); + $dialog = $this->get('helper.question'); + $session = $this->get('phpcr.session'); $noInteraction = $input->getOption('no-interaction'); if ($session->hasPendingChanges()) { diff --git a/src/PHPCR/Shell/Console/Command/Shell/PathChangeCommand.php b/src/PHPCR/Shell/Console/Command/Shell/PathChangeCommand.php index 2f090419..40fa6f4d 100644 --- a/src/PHPCR/Shell/Console/Command/Shell/PathChangeCommand.php +++ b/src/PHPCR/Shell/Console/Command/Shell/PathChangeCommand.php @@ -3,11 +3,11 @@ namespace PHPCR\Shell\Console\Command\Shell; use PHPCR\PathNotFoundException; -use Symfony\Component\Console\Command\Command; +use PHPCR\Shell\Console\Command\BaseCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class PathChangeCommand extends Command +class PathChangeCommand extends BaseCommand { protected function configure() { @@ -18,7 +18,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); try { $session->chdir($path); diff --git a/src/PHPCR/Shell/Console/Command/Shell/PathShowCommand.php b/src/PHPCR/Shell/Console/Command/Shell/PathShowCommand.php index 9f2396e6..7b5fbdc7 100644 --- a/src/PHPCR/Shell/Console/Command/Shell/PathShowCommand.php +++ b/src/PHPCR/Shell/Console/Command/Shell/PathShowCommand.php @@ -4,9 +4,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use PHPCR\Shell\Console\Command\BaseCommand; -class PathShowCommand extends Command +class PathShowCommand extends BaseCommand { protected function configure() { @@ -17,7 +17,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { $output->writeln( - '' . $this->getHelper('phpcr')->getSession()->getCwd() . '' + '' . $this->get('phpcr.session')->getCwd() . '' ); } } diff --git a/src/PHPCR/Shell/Console/Command/ShellCommand.php b/src/PHPCR/Shell/Console/Command/ShellCommand.php index 19a43fa7..d003c6f5 100644 --- a/src/PHPCR/Shell/Console/Command/ShellCommand.php +++ b/src/PHPCR/Shell/Console/Command/ShellCommand.php @@ -78,6 +78,10 @@ public function execute(InputInterface $input, OutputInterface $output) $application->setShowUnsupported($showUnspported); $application->dispatchProfileInitEvent($input, $output); + if ($input->getOption('verbose')) { + $application->setDebug(true); + } + $noInteraction = $input->getOption('no-interaction'); if ($commands = $input->getOption('command')) { diff --git a/src/PHPCR/Shell/Console/Helper/PhpcrHelper.php b/src/PHPCR/Shell/Console/Helper/PhpcrHelper.php index 12a927de..5375ab54 100644 --- a/src/PHPCR/Shell/Console/Helper/PhpcrHelper.php +++ b/src/PHPCR/Shell/Console/Helper/PhpcrHelper.php @@ -3,147 +3,35 @@ namespace PHPCR\Shell\Console\Helper; use Symfony\Component\Console\Helper\Helper; - -use PHPCR\Shell\Config\Profile; -use PHPCR\Shell\PhpcrSession; -use PHPCR\SimpleCredentials; -use PHPCR\Shell\Transport\TransportRegistryInterface; +use PHPCR\Shell\Phpcr\SessionManager; use PHPCR\SessionInterface; /** - * Helper for managing PHPCR sessions + * @deprecated + * + * This helper is deprecated and only exists to provide a backwards compatible + * API fo rsetting the PHPCR session as used in the DoctrinePHPCRBundle. + * + * It has since been replaced by the SessionManager service. * * @author Daniel Leech */ class PhpcrHelper extends Helper { - /** - * Active PHPCR session - * - * @var \PHPCR\SessionInterface - */ - protected $session; + private $sessionManager; - /** - * The transport registry - * - * @var TransportRegistryInterface - */ - protected $transportRegistry; - - /** - * @param TransportRegistryInterface $transportRegistry - * @param Profile $profile - */ - public function __construct(TransportRegistryInterface $transportRegistry, Profile $profile) + public function __construct(SessionManager $sessionManager) { - $this->transportRegistry = $transportRegistry; - $this->profile = $profile; - } - - /** - * {@inheritDoc} - */ - public function getName() - { - return 'phpcr'; - } - - private function init() - { - if (null === $this->session) { - $this->initSession(); - } + $this->sessionManager = $sessionManager; } public function setSession(SessionInterface $session) { - $this->session = $session; - } - - /** - * Initialize the PHPCR session - * - * @access private - */ - private function initSession() - { - $transport = $this->transportRegistry->getTransport($this->profile->get('transport', 'name')); - $repository = $transport->getRepository($this->profile->get('transport')); - - $credentials = new SimpleCredentials( - $this->profile->get('phpcr', 'username'), - $this->profile->get('phpcr', 'password') - ); - - $session = $repository->login($credentials, $this->profile->get('phpcr', 'workspace')); - - // if you are wondering wtf here -- we wrap the PhpcrSession - if (!$this->session) { - $this->session = new PhpcrSession($session); - } else { - $this->session->setPhpcrSession($session); - } - } - - /** - * Change the current workspace - * - * @param string $workspaceName - */ - public function changeWorkspace($workspaceName) - { - $this->init(); - $this->session->logout(); - $this->profile->set('phpcr', 'workspace', $workspaceName); - $this->initSession($this->profile); + $this->sessionManager->setSession($session); } - /** - * Login (again) - * - * @param string $username - * @param string $password - * @param string $workspaceName - */ - public function relogin($username, $password, $workspaceName = null) - { - if ($this->session) { - $this->session->logout(); - } - - $this->profile->set('phpcr', 'username', $username); - $this->profile->set('phpcr', 'password', $password); - - if ($workspaceName) { - $this->profile->set('phpcr', 'workspace', $workspaceName); - } - - $this->init(); - } - - /** - * Return the current PHPCR session. We lazy call - * initialize. - * - * @return \PHPCR\SessionInterface - */ - public function getSession() - { - $this->init(); - - return $this->session; - } - - /** - * Proxy for getting the repository (make mocking easier) - * - * @return \PHPCR\RepositoryInterface - */ - public function getRepository() + public function getName() { - $this->init(); - - return $this->session->getRepository(); + return 'phpcr'; } } diff --git a/src/PHPCR/Shell/Console/Helper/RepositoryHelper.php b/src/PHPCR/Shell/Console/Helper/RepositoryHelper.php index 32ca271e..635d809a 100644 --- a/src/PHPCR/Shell/Console/Helper/RepositoryHelper.php +++ b/src/PHPCR/Shell/Console/Helper/RepositoryHelper.php @@ -3,26 +3,27 @@ namespace PHPCR\Shell\Console\Helper; use Symfony\Component\Console\Helper\Helper; +use PHPCR\Shell\Phpcr\SessionManager; class RepositoryHelper extends Helper { /** * @var PhpcrHelper */ - protected $phpcrHelper; + protected $sessionManager; /** * @var array */ protected $descriptors; - public function __construct(PhpcrHelper $phpcrHelper) + public function __construct(SessionManager $sessionManager) { - $this->phpcrHelper = $phpcrHelper; + $this->sessionManager = $sessionManager; } /** - * Return true if the phpcrHelper supports the given descriptor + * Return true if the sessionManager supports the given descriptor * which relates to a descriptor key * * @param string $descriptor @@ -61,7 +62,7 @@ public function hasDescriptor($descriptor, $value = null) private function loadDescriptors() { if (null === $this->descriptors) { - $repository = $this->phpcrHelper->getRepository(); + $repository = $this->sessionManager->getRepository(); foreach ($repository->getDescriptorKeys() as $key) { $this->descriptors[$key] = $repository->getDescriptor($key); diff --git a/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php b/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php index d1f30012..3fe28243 100644 --- a/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php +++ b/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php @@ -3,13 +3,11 @@ namespace PHPCR\Shell\Console\Helper; use Symfony\Component\Console\Helper\Helper; -use Symfony\Component\Console\Helper\TableHelper; use PHPCR\Query\QueryResultInterface; use Symfony\Component\Console\Output\OutputInterface; use PHPCR\PropertyType; use PHPCR\NodeInterface; use PHPCR\PropertyInterface; -use PHPCR\Shell\Console\Helper\TextHelper; /** * Provide methods for formatting PHPCR objects @@ -19,10 +17,12 @@ class ResultFormatterHelper extends Helper { protected $textHelper; + protected $tableHelper; - public function __construct(TextHelper $textHelper) + public function __construct(TextHelper $textHelper, TableHelper $tableHelper) { $this->textHelper = $textHelper; + $this->tableHelper = $tableHelper; } /** @@ -33,7 +33,6 @@ public function getName() return 'result_formatter'; } - /** * Return the name of a property from its enumeration (i.e. * the value of its CONSTANT) @@ -57,7 +56,7 @@ public function formatQueryResult(QueryResultInterface $result, OutputInterface { $selectorNames = $result->getSelectorNames(); - $table = new TableHelper; + $table = $this->tableHelper->create(); $table->setHeaders(array_merge(array( 'Path', 'Index', diff --git a/src/PHPCR/Shell/Console/Helper/TableHelper.php b/src/PHPCR/Shell/Console/Helper/TableHelper.php index 41eaeb70..11daad71 100644 --- a/src/PHPCR/Shell/Console/Helper/TableHelper.php +++ b/src/PHPCR/Shell/Console/Helper/TableHelper.php @@ -17,7 +17,7 @@ class TableHelper extends Helper { public function create() { - return new OriginalTableHelper(); + return new OriginalTableHelper(false); } public function getName() diff --git a/src/PHPCR/Shell/DependencyInjection/Container.php b/src/PHPCR/Shell/DependencyInjection/Container.php new file mode 100644 index 00000000..669aad0a --- /dev/null +++ b/src/PHPCR/Shell/DependencyInjection/Container.php @@ -0,0 +1,151 @@ + 'PHPCR\Shell\Transport\Transport\DoctrineDbal', + 'transport.transport.jackrabbit' => 'PHPCR\Shell\Transport\Transport\Jackrabbit', + ); + + public function __construct($mode = self::MODE_STANDALONE) + { + parent::__construct(); + $this->mode = $mode; + + $this->registerHelpers(); + $this->registerConfig(); + $this->registerPhpcr(); + $this->registerEvent(); + } + + public function registerHelpers() + { + $this->register('helper.question', 'Symfony\Component\Console\Helper\DialogHelper'); + $this->register('helper.editor', 'PHPCR\Shell\Console\Helper\EditorHelper'); + $this->register('helper.path', 'PHPCR\Shell\Console\Helper\PathHelper'); + $this->register('helper.repository', 'PHPCR\Shell\Console\Helper\RepositoryHelper') + ->addArgument(new Reference('phpcr.session_manager')); + $this->register('helper.text', 'PHPCR\Shell\Console\Helper\TextHelper'); + $this->register('helper.node', 'PHPCR\Shell\Console\Helper\NodeHelper'); + $this->register('helper.result_formatter', 'PHPCR\Shell\Console\Helper\ResultFormatterHelper') + ->addArgument(new Reference('helper.text')) + ->addArgument(new Reference('helper.table')); + $this->register('helper.table', 'PHPCR\Shell\Console\Helper\TableHelper'); + } + + public function registerConfig() + { + $this->register('config.manager', 'PHPCR\Shell\Config\ConfigManager') + ->addArgument(new Reference('helper.question')); + + $this->register('config.profile', 'PHPCR\Shell\Config\Profile'); + $this->register('config.profile_loader', 'PHPCR\Shell\Config\ProfileLoader') + ->addArgument(new Reference('config.manager')); + } + + public function registerPhpcr() + { + // transports + foreach ($this->transports as $id => $class) { + $this->register($id, $class)->addArgument(new Reference('config.profile')); + } + + $registry = $this->register('phpcr.transport_registry', 'PHPCR\Shell\Transport\TransportRegistry'); + + foreach (array_keys($this->transports) as $transportId) { + $registry->addMethodCall('register', array(new Reference($transportId))); + } + + $this->register('phpcr.session_manager.active', 'PHPCR\Shell\Phpcr\SessionManager') + ->addArgument(new Reference('phpcr.transport_registry')) + ->addArgument(new Reference('config.profile')); + + $this->register('phpcr.session_manager.passive', 'PHPCR\Shell\Phpcr\SessionManager') + ->addArgument(new Reference('phpcr.transport_registry')) + ->addArgument(new Reference('config.profile')); + + $this->setAlias('phpcr.session_manager', 'phpcr.session_manager.active'); + + $repositoryDefinition = $this->register('phpcr.repository'); + $sessionDefinition = $this->register('phpcr.session'); + + if (method_exists($repositoryDefinition, 'setFactory')) { + $repositoryDefinition->setFactory(array(new Reference('phpcr.session_manager'), 'getRepository')); + $sessionDefinition->setFactory(array(new Reference('phpcr.session_manager'), 'getSession')); + } else { + $repositoryDefinition->setFactoryService('phpcr.session_manager')->setFactoryMethod('getRepository'); + $sessionDefinition->setFactoryService('phpcr.session_manager')->setFactoryMethod('getSession'); + } + } + + public function registerEvent() + { + if ($this->mode === self::MODE_STANDALONE) { + $this->register( + 'event.subscriber.profile_from_session_input', + 'PHPCR\Shell\Subscriber\ProfileFromSessionInputSubscriber' + )->addTag('event.subscriber'); + + $this->register( + 'event.subscriber.profile_writer', + 'PHPCR\Shell\Subscriber\ProfileWriterSubscriber' + ) + ->addArgument(new Reference('config.profile_loader')) + ->addArgument(new Reference('helper.question')) + ->addTag('event.subscriber'); + + $this->register( + 'event.subscriber.profile_loader', + 'PHPCR\Shell\Subscriber\ProfileLoaderSubscriber' + ) + ->addArgument(new Reference('config.profile_loader')) + ->addArgument(new Reference('helper.question')) + ->addTag('event.subscriber'); + + $this->register( + 'event.subscriber.config_init', + 'PHPCR\Shell\Subscriber\ConfigInitSubscriber' + ) + ->addArgument(new Reference('config.manager')) + ->addTag('event.subscriber'); + + } + + $this->register( + 'event.subscriber.alias', + 'PHPCR\Shell\Subscriber\AliasSubscriber' + ) + ->addArgument(new Reference('config.manager')) + ->addTag('event.subscriber'); + + $this->register( + 'event.subscriber.exception', + 'PHPCR\Shell\Subscriber\ExceptionSubscriber' + )->addTag('event.subscriber'); + + $dispatcher = $this->register('event.dispatcher', 'Symfony\Component\EventDispatcher\EventDispatcher'); + + foreach (array_keys($this->findTaggedServiceIds('event.subscriber')) as $id) { + $dispatcher->addMethodCall('addSubscriber', array(new Reference($id))); + } + } + + public function getMode() + { + return $this->mode; + } +} diff --git a/src/PHPCR/Shell/Event/ApplicationInitEvent.php b/src/PHPCR/Shell/Event/ApplicationInitEvent.php index c0cde764..a5deaa3e 100644 --- a/src/PHPCR/Shell/Event/ApplicationInitEvent.php +++ b/src/PHPCR/Shell/Event/ApplicationInitEvent.php @@ -20,9 +20,9 @@ public function __construct(Application $application) $this->application = $application; } - public function getApplication() + public function getApplication() { return $this->application; } - + } diff --git a/src/PHPCR/Shell/Event/CommandExceptionEvent.php b/src/PHPCR/Shell/Event/CommandExceptionEvent.php index 3f6f84ce..027c1b04 100644 --- a/src/PHPCR/Shell/Event/CommandExceptionEvent.php +++ b/src/PHPCR/Shell/Event/CommandExceptionEvent.php @@ -4,19 +4,19 @@ use Symfony\Component\EventDispatcher\Event; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use PHPCR\Shell\Console\Application\ShellApplication; class CommandExceptionEvent extends Event { protected $exception; protected $output; - protected $input; + protected $application; - public function __construct(\Exception $exception, InputInterface $input, OutputInterface $output) + public function __construct(\Exception $exception, ShellApplication $application, OutputInterface $output) { $this->exception = $exception; $this->output = $output; - $this->input = $input; + $this->application = $application; } public function getException() @@ -29,8 +29,8 @@ public function getOutput() return $this->output; } - public function getInput() + public function getApplication() { - return $this->input; + return $this->application; } } diff --git a/src/PHPCR/Shell/Event/ProfileInitEvent.php b/src/PHPCR/Shell/Event/ProfileInitEvent.php index 7ab509a4..ffd6f36b 100644 --- a/src/PHPCR/Shell/Event/ProfileInitEvent.php +++ b/src/PHPCR/Shell/Event/ProfileInitEvent.php @@ -28,12 +28,12 @@ public function __construct(Profile $profile, InputInterface $input, OutputInter $this->output = $output; } - public function getInput() + public function getInput() { return $this->input; } - public function getOutput() + public function getOutput() { return $this->output; } diff --git a/src/PHPCR/Shell/Phpcr/PhpcrSession.php b/src/PHPCR/Shell/Phpcr/PhpcrSession.php new file mode 100644 index 00000000..62094f01 --- /dev/null +++ b/src/PHPCR/Shell/Phpcr/PhpcrSession.php @@ -0,0 +1,359 @@ + + */ +class PhpcrSession implements SessionInterface +{ + protected $session; + protected $cwd = '/'; + + public function __construct(SessionInterface $session) + { + $this->session = $session; + } + + /** + * Allow underlying session to be changed + * For example when changing workspaces + * + * @param SessionInterface $session + */ + public function setPhpcrSession(SessionInterface $session) + { + $this->session = $session; + } + + public function getCurrentNode() + { + return $this->getNode($this->getCwd()); + } + + public function getCwd() + { + return $this->cwd; + } + + public function setCwd($cwd) + { + $this->cwd = $cwd; + } + + /** + * @TODO: Refactor this. + */ + public function autocomplete($text) + { + // return autocompletions for current path + $cwd = $this->getCwd(); + try { + $node = $this->getNode($cwd); + $list = (array) $node->getNodeNames(); + foreach ($node->getProperties() as $name => $v) { + $list[] = $name; + } + + return $list; + } catch (PathNotFoundException $e) { + return false; + } + } + + public function chdir($path) + { + $cwd = $this->getCwd(); + + if (UUIDHelper::isUUID($path)) { + $node = $this->getNodeByIdentifier($path); + $newPath = $node->getPath(); + } else { + // absolute path + if (substr($path, 0, 1) == '/') { + $newPath = $path; + } elseif ($path == '..') { + $newPath = dirname($cwd); + } else { + if ($this->cwd == '/') { + $newPath = sprintf('/%s', $path); + } else { + $newPath = sprintf('%s/%s', $cwd, $path); + } + } + + // check that path is valid + $this->getNode($newPath); + } + + $this->setCwd($newPath); + } + + public function getAbsPath($path) + { + if (!$path || $path === '.') { + return $this->getCwd(); + } + + if (substr($path, 0, 1) == '/') { + $absPath = $path; + } else { + if ($this->cwd == '/') { + $absPath = sprintf('/%s', $path); + } else { + $absPath = sprintf('%s/%s', $this->getCwd(), $path); + } + } + + return $absPath; + } + + /** + * Infer the absolute target path for a given source path. + * + * This means that if there is a node at targetPath then we + * will return append the basename of $srcPath to $targetPath. + * + * @param string $srcPath + * @param string $targetPath + * + * @return string + */ + public function getAbsTargetPath($srcPath, $targetPath) + { + $targetPath = $this->getAbsPath($targetPath); + + try { + $this->getNode($targetPath); + } catch (PathNotFoundException $e) { + return $targetPath; + } + + $basename = basename($this->getAbsPath($srcPath)); + + return $this->getAbsPath(sprintf('%s/%s', $targetPath, $basename)); + } + + public function getAbsPaths($paths) + { + $newPaths = array(); + foreach ($paths as $path) { + $newPaths[] = $this->getAbsPath($path); + } + + return $newPaths; + } + + /** + * If the given parameter looks like a UUID retrieve + * by Identifier, otherwise by path. + * + * @param string $pathOrId + * + * @return NodeInterface + * + * @throws PathNotFoundException if no accessible node is found at the specified path. + * @throws ItemNotFoundException if no node with the specified + * identifier exists or if this Session does not have read access to + * the node with the specified identifier. + */ + public function getNodeByPathOrIdentifier($pathOrId) + { + if (true === UUIDHelper::isUUID($pathOrId)) { + return $this->getNodeByIdentifier($pathOrId); + } + + $path = $this->getAbsPath($pathOrId); + + return $this->getNode($pathOrId); + } + + public function getRepository() + { + return $this->session->getRepository(); + } + + public function getUserID() + { + return $this->session->getUserID(); + } + + public function getAttributeNames() + { + return $this->session->getAttributeNames(); + } + + public function getAttribute($name) + { + return $this->session->getAttribute($name); + } + + public function getWorkspace() + { + return $this->session->getWorkspace(); + } + + public function getRootNode() + { + return $this->session->getRootNode(); + } + + public function impersonate(CredentialsInterface $credentials) + { + return $this->session->impersonate($credentials); + } + + public function getNodeByIdentifier($id) + { + return $this->session->getNodeByIdentifier($id); + } + + public function getNodesByIdentifier($ids) + { + return $this->session->getNodesByIdentifier($id); + } + + public function getItem($path) + { + return $this->session->getItem($this->getAbsPath($path)); + } + + public function getNode($path, $depthHint = -1) + { + return $this->session->getNode($this->getAbsPath($path)); + } + + public function getNodes($paths) + { + return $this->session->getNodes($this->getAbsPaths($paths)); + } + + public function getProperty($path) + { + return $this->session->getProperty($this->getAbsPath($path)); + } + + public function getProperties($paths) + { + return $this->session->getProperties($this->getAbsPaths($paths)); + } + + public function itemExists($path) + { + return $this->session->itemExists($this->getAbsPath($path)); + } + + public function nodeExists($path) + { + return $this->session->nodeExists($this->getAbsPath($path)); + } + + public function propertyExists($path) + { + return $this->session->propertyExists($this->getAbsPath($path)); + } + + public function move($srcPath, $destPath) + { + return $this->session->move($this->getAbsPath($srcPath), $this->getAbsTargetPath($srcPath, $destPath)); + } + + public function removeItem($path) + { + return $this->session->removeItem($this->getAbsPath($path)); + } + + public function save() + { + return $this->session->save(); + } + + public function refresh($keepChanges) + { + return $this->session->refresh($keepChanges); + } + + public function hasPendingChanges() + { + return $this->session->hasPendingChanges(); + } + + public function hasPermission($path, $actions) + { + return $this->session->hasPermission($this->getAbsPath($path), $actions); + } + + public function checkPermission($path, $actions) + { + return $this->session->checkPermission($this->getAbsPath($path), $actions); + } + + public function hasCapability($methodName, $target, array $arguments) + { + return $this->session->hasCapability($methodNames, $target, $arguments); + } + + public function importXML($parentAbsPath, $uri, $uuidBehavior) + { + return $this->session->importXML($this->getAbsPath($parentAbsPath), $uri, $uuidBehavior); + } + + public function exportSystemView($path, $stream, $skipBinary, $noRecurse) + { + return $this->session->exportSystemView($this->getAbsPath($path), $stream, $skipBinary, $noRecurse); + } + + public function exportDocumentView($path, $stream, $skipBinary, $noRecurse) + { + return $this->session->exportDocumentView($this->getAbsPath($path), $stream, $skipBinary, $noRecurse); + } + + public function setNamespacePrefix($prefix, $uri) + { + return $this->session->setNamespacePrefix($prefix, $uri); + } + + public function getNamespacePrefixes() + { + return $this->session->getNamespacePrefixes(); + } + + public function getNamespaceURI($prefix) + { + return $this->session->getNamespaceURI($prefix); + } + + public function getNamespacePrefix($uri) + { + return $this->session->getNamespacePrefix($uri); + } + + public function logout() + { + return $this->session->logout(); + } + + public function isLive() + { + return $this->session->isLive(); + } + + public function getAccessControlManager() + { + return $this->session->getAccessControlManager(); + } + + public function getRetentionManager() + { + return $this->session->getRetentionManager(); + } +} diff --git a/src/PHPCR/Shell/Phpcr/SessionManager.php b/src/PHPCR/Shell/Phpcr/SessionManager.php new file mode 100644 index 00000000..825299b9 --- /dev/null +++ b/src/PHPCR/Shell/Phpcr/SessionManager.php @@ -0,0 +1,138 @@ + + */ +class SessionManager +{ + /** + * Active PHPCR session + * + * @var \PHPCR\SessionInterface + */ + protected $session; + + /** + * The transport registry + * + * @var TransportRegistryInterface + */ + protected $transportRegistry; + + /** + * @param TransportRegistryInterface $transportRegistry + * @param Profile $profile + */ + public function __construct(TransportRegistryInterface $transportRegistry, Profile $profile) + { + $this->transportRegistry = $transportRegistry; + $this->profile = $profile; + } + + private function init() + { + if (null === $this->session) { + $this->initSession(); + } + } + + public function setSession(SessionInterface $session) + { + $this->session = $session; + } + + /** + * Initialize the PHPCR session + * + * @access private + */ + private function initSession() + { + $transport = $this->transportRegistry->getTransport($this->profile->get('transport', 'name')); + $repository = $transport->getRepository($this->profile->get('transport')); + + $credentials = new SimpleCredentials( + $this->profile->get('phpcr', 'username'), + $this->profile->get('phpcr', 'password') + ); + + $session = $repository->login($credentials, $this->profile->get('phpcr', 'workspace')); + + // if you are wondering wtf here -- we wrap the PhpcrSession + if (!$this->session) { + $this->session = new PhpcrSession($session); + } else { + $this->session->setPhpcrSession($session); + } + } + + /** + * Change the current workspace + * + * @param string $workspaceName + */ + public function changeWorkspace($workspaceName) + { + $this->init(); + $this->session->logout(); + $this->profile->set('phpcr', 'workspace', $workspaceName); + $this->initSession($this->profile); + } + + /** + * Login (again) + * + * @param string $username + * @param string $password + * @param string $workspaceName + */ + public function relogin($username, $password, $workspaceName = null) + { + if ($this->session) { + $this->session->logout(); + } + + $this->profile->set('phpcr', 'username', $username); + $this->profile->set('phpcr', 'password', $password); + + if ($workspaceName) { + $this->profile->set('phpcr', 'workspace', $workspaceName); + } + + $this->init(); + } + + /** + * Return the current PHPCR session. We lazy call + * initialize. + * + * @return \PHPCR\SessionInterface + */ + public function getSession() + { + $this->init(); + + return $this->session; + } + + /** + * Proxy for getting the repository (make mocking easier) + * + * @return \PHPCR\RepositoryInterface + */ + public function getRepository() + { + $this->init(); + + return $this->session->getRepository(); + } +} diff --git a/src/PHPCR/Shell/PhpcrSession.php b/src/PHPCR/Shell/PhpcrSession.php index 2e3f75e4..aff10f3d 100644 --- a/src/PHPCR/Shell/PhpcrSession.php +++ b/src/PHPCR/Shell/PhpcrSession.php @@ -2,353 +2,11 @@ namespace PHPCR\Shell; -use PHPCR\SessionInterface; -use PHPCR\CredentialsInterface; -use PHPCR\Util\PathHelper; -use PHPCR\Util\UUIDHelper; -use PHPCR\PathNotFoundException; +use PHPCR\Shell\Phpcr\PhpcrSession as RealPhpcrSession; -class PhpcrSession implements SessionInterface +/** + * @deprecated will be removed in 1.0 + */ +class PhpcrSession extends RealPhpcrSession { - protected $session; - protected $cwd = '/'; - - public function __construct(SessionInterface $session) - { - $this->session = $session; - } - - /** - * Allow underlying session to be changed - * For example when changing workspaces - * - * @param SessionInterface $session - */ - public function setPhpcrSession(SessionInterface $session) - { - $this->session = $session; - } - - public function getCurrentNode() - { - return $this->getNode($this->getCwd()); - } - - public function getCwd() - { - return $this->cwd; - } - - public function setCwd($cwd) - { - $this->cwd = $cwd; - } - - /** - * @TODO: Refactor this. - */ - public function autocomplete($text) - { - // return autocompletions for current path - $cwd = $this->getCwd(); - try { - $node = $this->getNode($cwd); - $list = (array) $node->getNodeNames(); - foreach ($node->getProperties() as $name => $v) { - $list[] = $name; - } - - return $list; - } catch (PathNotFoundException $e) { - return false; - } - } - - public function chdir($path) - { - $cwd = $this->getCwd(); - - if (UUIDHelper::isUUID($path)) { - $node = $this->getNodeByIdentifier($path); - $newPath = $node->getPath(); - } else { - // absolute path - if (substr($path, 0, 1) == '/') { - $newPath = $path; - } elseif ($path == '..') { - $newPath = dirname($cwd); - } else { - if ($this->cwd == '/') { - $newPath = sprintf('/%s', $path); - } else { - $newPath = sprintf('%s/%s', $cwd, $path); - } - } - - // check that path is valid - $this->getNode($newPath); - } - - $this->setCwd($newPath); - } - - public function getAbsPath($path) - { - if (!$path || $path === '.') { - return $this->getCwd(); - } - - if (substr($path, 0, 1) == '/') { - $absPath = $path; - } else { - if ($this->cwd == '/') { - $absPath = sprintf('/%s', $path); - } else { - $absPath = sprintf('%s/%s', $this->getCwd(), $path); - } - } - - return $absPath; - } - - /** - * Infer the absolute target path for a given source path. - * - * This means that if there is a node at targetPath then we - * will return append the basename of $srcPath to $targetPath. - * - * @param string $srcPath - * @param string $targetPath - * - * @return string - */ - public function getAbsTargetPath($srcPath, $targetPath) - { - $targetPath = $this->getAbsPath($targetPath); - - try { - $this->getNode($targetPath); - } catch (PathNotFoundException $e) { - return $targetPath; - } - - $basename = basename($this->getAbsPath($srcPath)); - - return $this->getAbsPath(sprintf('%s/%s', $targetPath, $basename)); - } - - public function getAbsPaths($paths) - { - $newPaths = array(); - foreach ($paths as $path) { - $newPaths[] = $this->getAbsPath($path); - } - - return $newPaths; - } - - - /** - * If the given parameter looks like a UUID retrieve - * by Identifier, otherwise by path. - * - * @param string $pathOrId - * - * @return NodeInterface - * - * @throws PathNotFoundException if no accessible node is found at the specified path. - * @throws ItemNotFoundException if no node with the specified - * identifier exists or if this Session does not have read access to - * the node with the specified identifier. - */ - public function getNodeByPathOrIdentifier($pathOrId) - { - if (true === UUIDHelper::isUUID($pathOrId)) { - return $this->getNodeByIdentifier($pathOrId); - } - - $path = $this->getAbsPath($pathOrId); - return $this->getNode($pathOrId); - } - - - public function getRepository() - { - return $this->session->getRepository(); - } - - public function getUserID() - { - return $this->session->getUserID(); - } - - public function getAttributeNames() - { - return $this->session->getAttributeNames(); - } - - public function getAttribute($name) - { - return $this->session->getAttribute($name); - } - - public function getWorkspace() - { - return $this->session->getWorkspace(); - } - - public function getRootNode() - { - return $this->session->getRootNode(); - } - - public function impersonate(CredentialsInterface $credentials) - { - return $this->session->impersonate($credentials); - } - - public function getNodeByIdentifier($id) - { - return $this->session->getNodeByIdentifier($id); - } - - public function getNodesByIdentifier($ids) - { - return $this->session->getNodesByIdentifier($id); - } - - public function getItem($path) - { - return $this->session->getItem($this->getAbsPath($path)); - } - - public function getNode($path, $depthHint = -1) - { - return $this->session->getNode($this->getAbsPath($path)); - } - - public function getNodes($paths) - { - return $this->session->getNodes($this->getAbsPaths($paths)); - } - - public function getProperty($path) - { - return $this->session->getProperty($this->getAbsPath($path)); - } - - public function getProperties($paths) - { - return $this->session->getProperties($this->getAbsPaths($paths)); - } - - public function itemExists($path) - { - return $this->session->itemExists($this->getAbsPath($path)); - } - - public function nodeExists($path) - { - return $this->session->nodeExists($this->getAbsPath($path)); - } - - public function propertyExists($path) - { - return $this->session->propertyExists($this->getAbsPath($path)); - } - - public function move($srcPath, $destPath) - { - return $this->session->move($this->getAbsPath($srcPath), $this->getAbsTargetPath($srcPath, $destPath)); - } - - public function removeItem($path) - { - return $this->session->removeItem($this->getAbsPath($path)); - } - - public function save() - { - return $this->session->save(); - } - - public function refresh($keepChanges) - { - return $this->session->refresh($keepChanges); - } - - public function hasPendingChanges() - { - return $this->session->hasPendingChanges(); - } - - public function hasPermission($path, $actions) - { - return $this->session->hasPermission($this->getAbsPath($path), $actions); - } - - public function checkPermission($path, $actions) - { - return $this->session->checkPermission($this->getAbsPath($path), $actions); - } - - public function hasCapability($methodName, $target, array $arguments) - { - return $this->session->hasCapability($methodNames, $target, $arguments); - } - - public function importXML($parentAbsPath, $uri, $uuidBehavior) - { - return $this->session->importXML($this->getAbsPath($parentAbsPath), $uri, $uuidBehavior); - } - - public function exportSystemView($path, $stream, $skipBinary, $noRecurse) - { - return $this->session->exportSystemView($this->getAbsPath($path), $stream, $skipBinary, $noRecurse); - } - - public function exportDocumentView($path, $stream, $skipBinary, $noRecurse) - { - return $this->session->exportDocumentView($this->getAbsPath($path), $stream, $skipBinary, $noRecurse); - } - - public function setNamespacePrefix($prefix, $uri) - { - return $this->session->setNamespacePrefix($prefix, $uri); - } - - public function getNamespacePrefixes() - { - return $this->session->getNamespacePrefixes(); - } - - public function getNamespaceURI($prefix) - { - return $this->session->getNamespaceURI($prefix); - } - - public function getNamespacePrefix($uri) - { - return $this->session->getNamespacePrefix($uri); - } - - public function logout() - { - return $this->session->logout(); - } - - public function isLive() - { - return $this->session->isLive(); - } - - public function getAccessControlManager() - { - return $this->session->getAccessControlManager(); - } - - public function getRetentionManager() - { - return $this->session->getRetentionManager(); - } } diff --git a/src/PHPCR/Shell/Query/ColumnOperand.php b/src/PHPCR/Shell/Query/ColumnOperand.php index 93c71be6..1cc0eb4b 100644 --- a/src/PHPCR/Shell/Query/ColumnOperand.php +++ b/src/PHPCR/Shell/Query/ColumnOperand.php @@ -19,12 +19,12 @@ public function __construct($selectorName, $propertyName) $this->propertyName = $propertyName; } - public function getSelectorName() + public function getSelectorName() { return $this->selectorName; } - public function getPropertyName() + public function getPropertyName() { return $this->propertyName; } diff --git a/src/PHPCR/Shell/Query/FunctionOperand.php b/src/PHPCR/Shell/Query/FunctionOperand.php index a3308677..8be1f28e 100644 --- a/src/PHPCR/Shell/Query/FunctionOperand.php +++ b/src/PHPCR/Shell/Query/FunctionOperand.php @@ -2,7 +2,6 @@ namespace PHPCR\Shell\Query; -use PHPCR\Shell\Query\ColumnOperand; use PHPCR\Query\RowInterface; /** @@ -107,7 +106,7 @@ public function getFunctionName() * * @return mixed */ - public function getArguments() + public function getArguments() { return $this->arguments; } diff --git a/src/PHPCR/Shell/Query/UpdateParser.php b/src/PHPCR/Shell/Query/UpdateParser.php index 37237ffc..6a73982b 100644 --- a/src/PHPCR/Shell/Query/UpdateParser.php +++ b/src/PHPCR/Shell/Query/UpdateParser.php @@ -2,7 +2,6 @@ namespace PHPCR\Shell\Query; -use PHPCR\Util\ValueConverter; use PHPCR\Query\InvalidQueryException; use PHPCR\Query\QOM\SourceInterface; use PHPCR\Util\QOM\Sql2ToQomQueryConverter; @@ -22,12 +21,13 @@ public function parse($sql2) { $this->scanner = new Sql2Scanner($sql2); $this->sql2 = $sql2; + return $this->doParse($sql2); } /** * Parse an "SQL2" UPDATE statement and construct a query builder - * for selecting the rows and build a field => value mapping for the + * for selecting the rows and build a field => value mapping for the * update. * * @param string $sql2 @@ -75,7 +75,7 @@ private function doParse($sql2) * Parse the SET section of the query, returning * an array containing the property names ( , * 'name' => , @@ -145,6 +145,7 @@ private function parseOperand() if ($this->scanner->lookupNextToken(1) == '(') { $functionData = $this->parseFunction(); + return new FunctionOperand($functionData[0], $functionData[1]); } @@ -154,10 +155,12 @@ private function parseOperand() if ($token === 'NULL') { $this->scanner->fetchNextToken(); + return null; } $columnData = $this->scanColumn(); + return new ColumnOperand($columnData[0], $columnData[1]); } diff --git a/src/PHPCR/Shell/Query/UpdateProcessor.php b/src/PHPCR/Shell/Query/UpdateProcessor.php index c00eae00..103f5421 100644 --- a/src/PHPCR/Shell/Query/UpdateProcessor.php +++ b/src/PHPCR/Shell/Query/UpdateProcessor.php @@ -2,9 +2,6 @@ namespace PHPCR\Shell\Query; -use PHPCR\Shell\Query\FunctionOperand; -use PHPCR\NodeInterface; -use PHPCR\Query\InvalidQueryException; use PHPCR\Query\RowInterface; /** @@ -14,7 +11,7 @@ class UpdateProcessor { /** * Functions available when calling SET - * + * * @var \Closure[] */ private $functionMap = array(); @@ -52,6 +49,7 @@ public function __construct() // first argument is the operand array_shift($values); + return $values; }, 'array_replace_at' => function ($operand, $current, $index, $value) { diff --git a/src/PHPCR/Shell/Serializer/NodeNormalizer.php b/src/PHPCR/Shell/Serializer/NodeNormalizer.php index f658eda5..01b63fb0 100644 --- a/src/PHPCR/Shell/Serializer/NodeNormalizer.php +++ b/src/PHPCR/Shell/Serializer/NodeNormalizer.php @@ -47,7 +47,11 @@ public function normalize($node, $format = null, array $context = array()) $propertyName = $property->getName(); if (in_array($property->getType(), array(PropertyType::REFERENCE, PropertyType::WEAKREFERENCE))) { - $propertyValue = array_keys($propertyValue); + $nodesUuids = array(); + foreach ((array) $propertyValue as $node) { + $nodeUuids[] = $node->getIdentifier(); + } + $propertyValue = $nodeUuids; } $res[$propertyName] = array( @@ -185,6 +189,7 @@ private function isPropertyEditable(PropertyInterface $property) $this->notes[] = sprintf( 'Binary property "%s" has been omitted', $property->getName() ); + return false; } diff --git a/src/PHPCR/Shell/Serializer/YamlEncoder.php b/src/PHPCR/Shell/Serializer/YamlEncoder.php index 3e7fb1df..6d445b8c 100644 --- a/src/PHPCR/Shell/Serializer/YamlEncoder.php +++ b/src/PHPCR/Shell/Serializer/YamlEncoder.php @@ -2,7 +2,6 @@ namespace PHPCR\Shell\Serializer; -use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Yaml\Yaml; use Symfony\Component\Serializer\Encoder\EncoderInterface; use Symfony\Component\Serializer\Encoder\DecoderInterface; @@ -27,6 +26,7 @@ public function encode($data, $format, array $context = array()) public function decode($data, $format, array $context = array()) { $arr = Yaml::parse($data); + return $arr; } diff --git a/src/PHPCR/Shell/Subscriber/AliasSubscriber.php b/src/PHPCR/Shell/Subscriber/AliasSubscriber.php index ab59e11c..b01fcb38 100644 --- a/src/PHPCR/Shell/Subscriber/AliasSubscriber.php +++ b/src/PHPCR/Shell/Subscriber/AliasSubscriber.php @@ -3,11 +3,10 @@ namespace PHPCR\Shell\Subscriber; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use PHPCR\Shell\Console\Helper\ConfigHelper; use PHPCR\Shell\Event\PhpcrShellEvents; use PHPCR\Shell\Event\CommandPreRunEvent; use PHPCR\Shell\Console\Input\StringInput; -use Symfony\Component\Console\Helper\HelperSet; +use PHPCR\Shell\Config\ConfigManager; /** * Check to see if the input references a command alias and @@ -18,20 +17,13 @@ class AliasSubscriber implements EventSubscriberInterface { /** - * Lazy load helper - * - * @var HelperSet + * @var ConfigManager */ - protected $helperSet; - - public function __construct(HelperSet $helperSet) - { - $this->helperSet = $helperSet; - } + protected $configManager; - protected function getConfig() + public function __construct(ConfigManager $configManager) { - return $this->helperSet->get('config'); + $this->configManager = $configManager; } public static function getSubscribedEvents() @@ -53,7 +45,7 @@ public function handleAlias(CommandPreRunEvent $event) $commandName = $input->getFirstArgument(); - $aliasConfig = $this->getConfig()->getConfig('alias'); + $aliasConfig = $this->configManager->getConfig('alias'); if (!isset($aliasConfig[$commandName])) { return; diff --git a/src/PHPCR/Shell/Subscriber/AutoSaveSubscriber.php b/src/PHPCR/Shell/Subscriber/AutoSaveSubscriber.php index 6d397d4b..7cb0e284 100644 --- a/src/PHPCR/Shell/Subscriber/AutoSaveSubscriber.php +++ b/src/PHPCR/Shell/Subscriber/AutoSaveSubscriber.php @@ -24,7 +24,7 @@ public function handleTerminate(ConsoleTerminateEvent $event) { $command = $event->getCommand(); $output = $event->getOutput(); - $session = $command->getHelper('phpcr')->getSession(); + $session = $command->get('phpcr.session'); if ($session->hasPendingChanges()) { $output->writeln('Auto-saving session'); diff --git a/src/PHPCR/Shell/Subscriber/ConfigInitSubscriber.php b/src/PHPCR/Shell/Subscriber/ConfigInitSubscriber.php index fa4ab864..fa7f8134 100644 --- a/src/PHPCR/Shell/Subscriber/ConfigInitSubscriber.php +++ b/src/PHPCR/Shell/Subscriber/ConfigInitSubscriber.php @@ -5,6 +5,7 @@ use PHPCR\Shell\Event\PhpcrShellEvents; use PHPCR\Shell\Event\ApplicationInitEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use PHPCR\Shell\Config\ConfigManager; /** * Subscriber to initialize the configuration if it does not @@ -14,6 +15,13 @@ */ class ConfigInitSubscriber implements EventSubscriberInterface { + private $configManager; + + public function __construct(ConfigManager $configManager) + { + $this->configManager = $configManager; + } + public static function getSubscribedEvents() { return array( @@ -23,12 +31,10 @@ public static function getSubscribedEvents() public function handleApplicationInit(ApplicationInitEvent $event) { - $application = $event->getApplication(); - $config = $application->getHelperSet()->get('config'); - $configDir = $config->getConfigDir(); + $configDir = $this->configManager->getConfigDir(); if (!file_exists($configDir)) { - $config->initConfig(); + $this->configManager->initConfig(); } } } diff --git a/src/PHPCR/Shell/Subscriber/ExceptionSubscriber.php b/src/PHPCR/Shell/Subscriber/ExceptionSubscriber.php index c770c331..308e3f4f 100644 --- a/src/PHPCR/Shell/Subscriber/ExceptionSubscriber.php +++ b/src/PHPCR/Shell/Subscriber/ExceptionSubscriber.php @@ -25,14 +25,8 @@ public static function getSubscribedEvents() public function handleException(CommandExceptionEvent $event) { $exception = $event->getException(); - $input = $event->getInput(); $output = $event->getOutput(); - - // if verbose, just throw the whole exception back - if ($input->hasOption('verbose') && $input->getOption('verbose')) { - throw $exception; - } - + $application = $event->getApplication(); if ($exception instanceof UnsupportedRepositoryOperationException) { $output->writeln('Unsupported repository operation: This repository is not capable of performing the requested action'); @@ -43,5 +37,9 @@ public function handleException(CommandExceptionEvent $event) } $output->writeln('[' . get_class($exception) .'] ' . $exception->getMessage() . ''); + + if ($application->isDebug()) { + $output->writeln('' . $exception->getTraceAsString() . ''); + } } } diff --git a/src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php b/src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php index 081cd67b..69484005 100644 --- a/src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php +++ b/src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php @@ -5,7 +5,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use PHPCR\Shell\Event\PhpcrShellEvents; use PHPCR\Shell\Event\ProfileInitEvent; -use Symfony\Component\Console\Helper\DialogHelper; +use Symfony\Component\Console\Helper\QuestionHelper; use PHPCR\Shell\Config\ProfileLoader; use Symfony\Component\Console\Output\OutputInterface; use PHPCR\Shell\Config\Profile; @@ -13,7 +13,7 @@ class ProfileLoaderSubscriber implements EventSubscriberInterface { protected $profileLoader; - protected $dialogHelper; + protected $questionHelper; public static function getSubscribedEvents() { @@ -22,10 +22,10 @@ public static function getSubscribedEvents() ); } - public function __construct(ProfileLoader $profileLoader) + public function __construct(ProfileLoader $profileLoader, $questionHelper) { $this->profileLoader = $profileLoader; - $this->dialogHelper = new DialogHelper; + $this->questionHelper = $questionHelper; } public function handleProfileInit(ProfileInitEvent $e) @@ -73,15 +73,13 @@ public function handleProfileInit(ProfileInitEvent $e) $output->writeln('No connection parameters, given. Select an existing profile:'); $output->writeln(''); - foreach ($profileNames as $i => $profileName) { - $output->writeln(sprintf(' (%d) %s', $i, $profileName)); - } - - $output->writeln(''); - $selectedName = null; while (null === $selectedName) { - $number = $this->dialogHelper->ask($output, 'Enter profile number: '); + $number = $this->questionHelper->select( + $output, + 'Choose a profile: ', + $profileNames + ); if (!isset($profileNames[$number])) { $output->writeln('Invalid selection!'); diff --git a/src/PHPCR/Shell/Subscriber/ProfileWriterSubscriber.php b/src/PHPCR/Shell/Subscriber/ProfileWriterSubscriber.php index 0c3af5e8..bdcb188e 100644 --- a/src/PHPCR/Shell/Subscriber/ProfileWriterSubscriber.php +++ b/src/PHPCR/Shell/Subscriber/ProfileWriterSubscriber.php @@ -5,13 +5,13 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use PHPCR\Shell\Event\PhpcrShellEvents; use PHPCR\Shell\Event\ProfileInitEvent; -use Symfony\Component\Console\Helper\DialogHelper; +use Symfony\Component\Console\Helper\QuestionHelper; use PHPCR\Shell\Config\ProfileLoader; class ProfileWriterSubscriber implements EventSubscriberInterface { protected $profileLoader; - protected $dialogHelper; + protected $questionHelper; public static function getSubscribedEvents() { @@ -20,10 +20,10 @@ public static function getSubscribedEvents() ); } - public function __construct(ProfileLoader $profileLoader) + public function __construct(ProfileLoader $profileLoader, $questionHelper) { $this->profileLoader = $profileLoader; - $this->dialogHelper = new DialogHelper; + $this->questionHelper = $questionHelper; } public function handleProfileInit(ProfileInitEvent $e) @@ -41,10 +41,10 @@ public function handleProfileInit(ProfileInitEvent $e) $overwrite = false; if (file_exists($this->profileLoader->getProfilePath($profileName))) { - $res = $this->dialogHelper->askConfirmation($output, sprintf('Update existing profile "%s"?', $profileName)); + $res = $this->questionHelper->askConfirmation($output, sprintf('Update existing profile "%s"?', $profileName)); $overwrite = true; } else { - $res = $this->dialogHelper->askConfirmation($output, sprintf('Create new profile "%s"?', $profileName)); + $res = $this->questionHelper->askConfirmation($output, sprintf('Create new profile "%s"?', $profileName)); } if ($res) { @@ -53,4 +53,3 @@ public function handleProfileInit(ProfileInitEvent $e) } } } - diff --git a/src/PHPCR/Shell/Test/ApplicationTester.php b/src/PHPCR/Shell/Test/ApplicationTester.php index 0a2824a7..c0f157de 100644 --- a/src/PHPCR/Shell/Test/ApplicationTester.php +++ b/src/PHPCR/Shell/Test/ApplicationTester.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\StreamOutput; use PHPCR\Shell\Console\Input\StringInput; -use PHPCR\Shell\Console\Application\SessionApplication; +use PHPCR\Shell\Console\Application\ShellApplication; /** * Eases the testing of console applications. @@ -23,6 +23,7 @@ class ApplicationTester { private $application; + private $shellApplication; private $input; private $output; private $lastExitCode; @@ -32,9 +33,12 @@ class ApplicationTester * * @param Application $application An Application instance to test. */ - public function __construct() + public function __construct(Application $application, ShellApplication $shellApplication = null) { - $this->application = new SessionApplication(); + $this->output = new StreamOutput(fopen('php://memory', 'w', false)); + + $this->application = $application; + $this->shellApplication = $shellApplication; } /** @@ -55,7 +59,6 @@ public function run(array $input, $options = array()) { $this->input = new ArrayInput($input); - $this->output = new StreamOutput(fopen('php://memory', 'w', false)); if (isset($options['decorated'])) { $this->output->setDecorated($options['decorated']); } @@ -64,7 +67,10 @@ public function run(array $input, $options = array()) } $this->application->setAutoExit(false); - $this->application->getShellApplication()->setAutoExit(false); + + if ($this->shellApplication) { + $this->shellApplication->setAutoExit(false); + } $this->application->setCatchExceptions(false); return $this->application->run($this->input, $this->output); @@ -124,7 +130,12 @@ public function getOutput() public function runShellCommand($command) { - $ret = $this->application->getShellApplication()->run(new StringInput($command), $this->output); + if ($this->shellApplication) { + $ret = $this->shellApplication->run(new StringInput($command), $this->output); + } else { + $ret = $this->application->run(new StringInput($command), $this->output); + } + $this->lastExitCode = $ret; return $ret; diff --git a/features/bootstrap/FeatureContext.php b/src/PHPCR/Shell/Test/ContextBase.php similarity index 89% rename from features/bootstrap/FeatureContext.php rename to src/PHPCR/Shell/Test/ContextBase.php index b2be5fe8..a44b669f 100644 --- a/features/bootstrap/FeatureContext.php +++ b/src/PHPCR/Shell/Test/ContextBase.php @@ -1,16 +1,17 @@ workingDir, 0777, true); chdir($this->workingDir); $this->filesystem = new Filesystem(); - - $session = $this->getSession(null, true); - - $this->applicationTester = new ApplicationTester(); - $this->applicationTester->run(array( - '--transport' => 'jackrabbit', - '--no-interaction' => true, - '--unsupported' => true, // test all the commands, even if they are unsupported (we test for the fail) - ), array( - 'interactive' => true, - )); + $this->applicationTester = $this->createTester(); } /** @@ -71,7 +66,7 @@ public static function cleanTestFolders() $fs->remove(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'phpcr-shell'); } - private function getSession($workspaceName = null, $force = false) + protected function getSession($workspaceName = null, $force = false) { if ($workspaceName === null) { $workspaceName = $this->currentWorkspaceName; @@ -81,6 +76,7 @@ private function getSession($workspaceName = null, $force = false) if (false === $force && isset($sessions[$workspaceName])) { $session = $sessions[$workspaceName]; + return $session; } @@ -118,7 +114,7 @@ private function getXPathForFile($filename) private function getFixtureFilename($filename) { - $fixtureFile = realpath(__DIR__).'/../fixtures/'.$filename; + $fixtureFile = realpath(__DIR__).'/../../../../features/fixtures/'.$filename; if (!file_exists($fixtureFile)) { throw new \Exception('Fixtures do not exist at ' . $fixtureFile); } @@ -190,7 +186,7 @@ public function iShouldSeeATableContainingTheFollowingRows(TableNode $table) } } - PHPUnit_Framework_Assert::assertGreaterThanOrEqual(count($expectedRows), $foundRows, $this->getOutput()); + \PHPUnit_Framework_Assert::assertGreaterThanOrEqual(count($expectedRows), $foundRows, $this->getOutput()); } /** @@ -199,7 +195,7 @@ public function iShouldSeeATableContainingTheFollowingRows(TableNode $table) public function iShouldSeeTheFollowing(PyStringNode $string) { $output = $this->getOutput(); - PHPUnit_Framework_Assert::assertContains($string->getRaw(), $output); + \PHPUnit_Framework_Assert::assertContains($string->getRaw(), $output); } /** @@ -208,7 +204,7 @@ public function iShouldSeeTheFollowing(PyStringNode $string) public function iShouldNotSeeTheFollowing(PyStringNode $string) { $output = $this->getOutput(); - PHPUnit_Framework_Assert::assertNotContains($string->getRaw(), $output); + \PHPUnit_Framework_Assert::assertNotContains($string->getRaw(), $output); } /** @@ -220,6 +216,10 @@ public function theFixturesAreLoaded($arg1) $session = $this->getSession(null, true); NodeHelper::purgeWorkspace($session); $session->save(); + + // shouldn't have to do this, but this seems to be a bug in jackalope + $session->refresh(false); + $session->importXml('/', $fixtureFile, 0); $session->save(); } @@ -235,7 +235,7 @@ public function theCommandShouldNotFail() throw new \Exception('Command failed: (' . $exitCode . ') ' . $this->getOutput()); } - PHPUnit_Framework_Assert::assertEquals(0, $exitCode, 'Command exited with code: ' . $exitCode); + \PHPUnit_Framework_Assert::assertEquals(0, $exitCode, 'Command exited with code: ' . $exitCode); } /** @@ -245,7 +245,7 @@ public function theCommandShouldFail() { $exitCode = $this->applicationTester->getLastExitCode(); - PHPUnit_Framework_Assert::assertNotEquals(0, $exitCode, 'Command exited with code ' . $exitCode); + \PHPUnit_Framework_Assert::assertNotEquals(0, $exitCode, 'Command exited with code ' . $exitCode); } /** @@ -256,14 +256,14 @@ public function theCommandShouldFailWithMessage($arg1) $exitCode = $this->applicationTester->getLastExitCode(); $output = $this->getOutput(); - PHPUnit_Framework_Assert::assertEquals($arg1, $output); + \PHPUnit_Framework_Assert::assertEquals($arg1, $output); } /** * @Given /^the file "([^"]*)" should exist$/ */ public function theFileShouldExist($arg1) { - PHPUnit_Framework_Assert::assertTrue(file_exists($this->getWorkingFilePath($arg1))); + \PHPUnit_Framework_Assert::assertTrue(file_exists($this->getWorkingFilePath($arg1))); } /** @@ -289,8 +289,8 @@ public function theFileExists($arg1) */ public function theOutputShouldContain(PyStringNode $string) { - foreach ($string->getLines() as $line) { - PHPUnit_Framework_Assert::assertContains($line, $this->getOutput()); + foreach ($string->getStrings() as $line) { + \PHPUnit_Framework_Assert::assertContains($line, $this->getOutput()); } } @@ -301,7 +301,7 @@ public function theNodeShouldNotExist($arg1) { $session = $this->getSession(); $node = $session->getNode($arg1); - PHPUnit_Framework_Assert::assertNull($node); + \PHPUnit_Framework_Assert::assertNull($node); } /** @@ -312,7 +312,7 @@ public function theXpathCountIsInFile($arg1, $arg2, $arg3) $xpath = $this->getXPathForFile($arg3); $res = $xpath->query($arg1); - PHPUnit_Framework_Assert::assertEquals($arg2, $res->length); + \PHPUnit_Framework_Assert::assertEquals($arg2, $res->length); } /** @@ -349,13 +349,13 @@ public function iShouldNotBeLoggedIntoTheSession() { $this->executeCommand('session:info'); $output = $this->getOutput(); - PHPUnit_Framework_Assert::assertRegExp('/live .*no/', $output); + \PHPUnit_Framework_Assert::assertRegExp('/live .*no/', $output); } /** * @Given /^there exists a namespace prefix "([^"]*)" with URI "([^"]*)"$/ */ - public function thereExistsANamespacePrefixWithUri($arg1, $arg2) + public function thereExistsANamespacePrefixWithUri($arg, $arg2) { $session = $this->getSession(); $session->setNamespacePrefix($arg1, $arg2); @@ -381,8 +381,8 @@ public function thereShouldExistANodeAt($arg1) } catch (PathNotFoundException $e) { throw new \Exception('Node does at path ' . $arg1 . ' does not exist.'); } - } - + } + /** * @Given /^there should exist a node at "([^"]*)" before "([^"]*)"$/ */ @@ -412,7 +412,7 @@ public function thereShouldExistANodeAtBefore($arg1, $arg2) throw new \Exception('Could not find child node ' . $arg1); } - PHPUnit_Framework_Assert::assertEquals($arg2, $afterNode->getPath()); + \PHPUnit_Framework_Assert::assertEquals($arg2, $afterNode->getPath()); } /** @@ -513,7 +513,7 @@ public function thenIShouldBeLoggedInAs($arg1) $session = $this->getSession(); $userId = $session->getUserID(); - PHPUnit_Framework_Assert::assertEquals($userId, $arg1); + \PHPUnit_Framework_Assert::assertEquals($userId, $arg1); } /** @@ -669,7 +669,7 @@ public function theCurrentNodeShouldBe($arg1) { $this->executeCommand('shell:path:show'); $cnp = $this->applicationTester->getLastLine(); - PHPUnit_Framework_Assert::assertEquals($arg1, $cnp, 'Current path is ' . $arg1); + \PHPUnit_Framework_Assert::assertEquals($arg1, $cnp, 'Current path is ' . $arg1); } /** @@ -707,7 +707,7 @@ public function thePrimaryTypeOfShouldBe($arg1, $arg2) $session = $this->getSession(); $node = $session->getNode($arg1); $primaryTypeName = $node->getPrimaryNodeType()->getName(); - PHPUnit_Framework_Assert::assertEquals($arg2, $primaryTypeName, 'Node type of ' . $arg1 . ' is ' . $arg2); + \PHPUnit_Framework_Assert::assertEquals($arg2, $primaryTypeName, 'Node type of ' . $arg1 . ' is ' . $arg2); } /** @@ -719,7 +719,7 @@ public function theNodeAtShouldHaveThePropertyWithValue($arg1, $arg2, $arg3) $node = $session->getNode($arg1); $property = $node->getProperty($arg2); $propertyType = $property->getValue(); - PHPUnit_Framework_Assert::assertEquals($arg3, $propertyType); + \PHPUnit_Framework_Assert::assertEquals($arg3, $propertyType); } /** @@ -735,7 +735,7 @@ public function theNodeAtShouldHaveThePropertyWithValueAtIndex($arg1, $arg2, $ar } $propertyType = $property->getValue(); - PHPUnit_Framework_Assert::assertEquals($arg3, $propertyType[$index]); + \PHPUnit_Framework_Assert::assertEquals($arg3, $propertyType[$index]); } /** @@ -751,7 +751,7 @@ public function thePropertyShouldHaveType($arg1, $arg2) )); } - PHPUnit_Framework_Assert::assertEquals($arg2, PropertyType::nameFromValue($property->getType())); + \PHPUnit_Framework_Assert::assertEquals($arg2, PropertyType::nameFromValue($property->getType())); } @@ -768,8 +768,8 @@ public function thePropertyShouldHaveTypeAndValue($arg1, $arg2, $arg3) )); } - PHPUnit_Framework_Assert::assertEquals($arg2, PropertyType::nameFromValue($property->getType())); - PHPUnit_Framework_Assert::assertEquals($arg3, $property->getValue()); + \PHPUnit_Framework_Assert::assertEquals($arg2, PropertyType::nameFromValue($property->getType())); + \PHPUnit_Framework_Assert::assertEquals($arg3, $property->getValue()); } /** @@ -839,7 +839,7 @@ public function theNodeShouldBeLocked($arg1) $lockManager = $workspace->getLockManager(); $isLocked = $lockManager->isLocked($arg1); - PHPUnit_Framework_Assert::assertTrue($isLocked); + \PHPUnit_Framework_Assert::assertTrue($isLocked); } /** @@ -852,7 +852,7 @@ public function theNodeShouldNotBeLocked($arg1) $lockManager = $workspace->getLockManager(); $isLocked = $lockManager->isLocked($arg1); - PHPUnit_Framework_Assert::assertFalse($isLocked); + \PHPUnit_Framework_Assert::assertFalse($isLocked); } /** diff --git a/src/PHPCR/Shell/Test/EmbeddedContext.php b/src/PHPCR/Shell/Test/EmbeddedContext.php new file mode 100644 index 00000000..7109f70e --- /dev/null +++ b/src/PHPCR/Shell/Test/EmbeddedContext.php @@ -0,0 +1,27 @@ +getSession(null, true); + + $this->application = new EmbeddedApplication(EmbeddedApplication::MODE_SHELL); + $this->application->getHelperSet()->get('phpcr')->setSession(new PhpcrSession($session)); + + $tester = new ApplicationTester($this->application); + + return $tester; + } +} diff --git a/src/PHPCR/Shell/Test/StandaloneContext.php b/src/PHPCR/Shell/Test/StandaloneContext.php new file mode 100644 index 00000000..19232622 --- /dev/null +++ b/src/PHPCR/Shell/Test/StandaloneContext.php @@ -0,0 +1,27 @@ +getShellApplication(); + $tester = new ApplicationTester($sessionApplication, $shellApplication); + $tester->run(array( + '--transport' => 'jackrabbit', + '--no-interaction' => true, + '--unsupported' => true, // test all the commands, even if they are unsupported (we test for the fail) + ), array( + 'interactive' => true, + )); + + return $tester; + } +} diff --git a/src/PHPCR/Shell/Transport/Transport/DoctrineDbal.php b/src/PHPCR/Shell/Transport/Transport/DoctrineDbal.php index a8821fa6..358133ce 100644 --- a/src/PHPCR/Shell/Transport/Transport/DoctrineDbal.php +++ b/src/PHPCR/Shell/Transport/Transport/DoctrineDbal.php @@ -4,7 +4,6 @@ use Doctrine\DBAL\DriverManager; use Jackalope\RepositoryFactoryDoctrineDBAL; -use Symfony\Component\Console\Input\InputInterface; use PHPCR\Shell\Transport\TransportInterface; class DoctrineDbal implements TransportInterface diff --git a/src/PHPCR/Shell/Transport/Transport/Jackrabbit.php b/src/PHPCR/Shell/Transport/Transport/Jackrabbit.php index 72797f32..40443285 100644 --- a/src/PHPCR/Shell/Transport/Transport/Jackrabbit.php +++ b/src/PHPCR/Shell/Transport/Transport/Jackrabbit.php @@ -2,7 +2,6 @@ namespace PHPCR\Shell\Transport\Transport; -use Symfony\Component\Console\Input\InputInterface; use Jackalope\RepositoryFactoryJackrabbit; use PHPCR\Shell\Transport\TransportInterface; diff --git a/src/PHPCR/Shell/Transport/TransportRegistry.php b/src/PHPCR/Shell/Transport/TransportRegistry.php index 7e26a27e..ab313e48 100644 --- a/src/PHPCR/Shell/Transport/TransportRegistry.php +++ b/src/PHPCR/Shell/Transport/TransportRegistry.php @@ -2,9 +2,6 @@ namespace PHPCR\Shell\Transport; -use PHPCR\Shell\Transport\TransportInterface; -use PHPCR\Shell\Config\Profile; - class TransportRegistry implements TransportRegistryInterface { protected $transports = array(); diff --git a/src/PHPCR/Shell/Transport/TransportRegistryInterface.php b/src/PHPCR/Shell/Transport/TransportRegistryInterface.php index f83dc9fc..53c1339c 100644 --- a/src/PHPCR/Shell/Transport/TransportRegistryInterface.php +++ b/src/PHPCR/Shell/Transport/TransportRegistryInterface.php @@ -5,7 +5,7 @@ /** * Interface for transport factory * - * Note that transport registry is a bit of a misnomer - + * Note that transport registry is a bit of a misnomer - * logically it would be RepositoryFactoryInitializerInterface, * which is too long imo. * diff --git a/tests/PHPCR/Shell/Helper/EditorHelperTest.php b/tests/PHPCR/Shell/Helper/EditorHelperTest.php index e2dfdfac..21759e03 100644 --- a/tests/PHPCR/Shell/Helper/EditorHelperTest.php +++ b/tests/PHPCR/Shell/Helper/EditorHelperTest.php @@ -2,8 +2,6 @@ namespace PHPCR\Shell\Console\Helper; -use PHPCR\Shell\Console\Helper\EditorHelper; - class EditorHelperTest extends \PHPUnit_Framework_TestCase { protected $helper; @@ -48,7 +46,7 @@ public function provideFromStringWithMessage() <<helper->assertNodeIsVersionable($this->node); } } - diff --git a/tests/PHPCR/Shell/Helper/TextHelperTest.php b/tests/PHPCR/Shell/Helper/TextHelperTest.php index b3367ea6..9f589c06 100644 --- a/tests/PHPCR/Shell/Helper/TextHelperTest.php +++ b/tests/PHPCR/Shell/Helper/TextHelperTest.php @@ -2,15 +2,13 @@ namespace PHPCR\Shell\Console\Helper; -use PHPCR\Shell\Console\Helper\TextHelper; - class TextHelperTest extends \PHPUnit_Framework_TestCase { protected $textHelper; public function setUp() { - $this->textHelper = new TextHelper; + $this->textHelper = new TextHelper(); } public function provideTruncate() diff --git a/tests/PHPCR/Shell/PhpcrSessionTest.php b/tests/PHPCR/Shell/Phpcr/PhpcrSessionTest.php similarity index 98% rename from tests/PHPCR/Shell/PhpcrSessionTest.php rename to tests/PHPCR/Shell/Phpcr/PhpcrSessionTest.php index 26c84013..469f02fb 100644 --- a/tests/PHPCR/Shell/PhpcrSessionTest.php +++ b/tests/PHPCR/Shell/Phpcr/PhpcrSessionTest.php @@ -1,6 +1,6 @@ with($expSrc, $expTar); $this->phpcr->expects($this->once()) ->method('getNode') - ->will($this->throwException(new PathNotFoundException)); + ->will($this->throwException(new PathNotFoundException())); $this->session->setCwd($cwd); $this->session->move($relSrc, $relTar); }