From 777d232ce9e7624dcb0756745050fd92b77c0c73 Mon Sep 17 00:00:00 2001 From: mugge6 Date: Thu, 28 Nov 2024 11:56:29 +0100 Subject: [PATCH] Revert "Sync with latest upstream 4.x" --- .github/workflows/behat.yml | 54 +++-- .github/workflows/static.yml | 29 +-- behat-bootstrap.php | 18 +- composer.json | 19 +- config/config.yaml | 1 + config/migrations.yaml | 19 ++ config/packages/security.yaml | 49 +++-- config/packages/test/config.yaml | 9 - config/routes.yaml | 2 +- config/routes/dev/routes.yaml | 3 +- config/system.yml | 17 ++ features/cleaner/deleter.feature | 2 +- features/cleaner/none.feature | 2 +- features/cleaner/unpublisher.feature | 2 +- src/BehatKernel.php | 32 --- .../Command/ExportCommand.php | 15 +- .../Command/ImportAsyncCommand.php | 87 -------- .../Command/ImportCommand.php | 15 +- .../AbstractDefinitionController.php | 41 ---- .../Controller/ExportDefinitionController.php | 16 +- .../Controller/ImportDefinitionController.php | 43 ++-- .../Controller/ImportRuleController.php | 2 +- .../DataDefinitionsBundle.php | 11 +- .../DependencyInjection/Configuration.php | 87 -------- .../DataDefinitionsExtension.php | 16 +- .../EventListener/PimcoreSettingsListener.php | 29 --- .../EventListener/WriteableListener.php | 47 ----- .../Exporter/Exporter.php | 6 - .../Fetcher/ObjectsFetcher.php | 10 +- .../Form/Type/ExportDefinitionType.php | 1 - .../TypeCastingInterpreterType.php | 38 ---- .../Importer/AsyncImporterInterface.php | 26 --- .../Importer/Importer.php | 75 +------ .../Interpreter/TypeCastingInterpreter.php | 9 +- .../Messenger/ImportRowMessage.php | 46 ----- .../Messenger/ImportRowMessageHandler.php | 44 ---- .../Model/AbstractDataDefinition.php | 12 +- .../Model/DataDefinitionInterface.php | 4 + .../Model/ExportDefinition.php | 33 +-- .../Model/ExportDefinition/Dao.php | 167 ++++++++------- .../Model/ExportDefinition/Listing.php | 18 +- .../Model/ExportDefinition/Listing/Dao.php | 51 +++-- .../Model/ExportDefinitionInterface.php | 10 - .../Model/ImportDefinition.php | 12 +- .../Model/ImportDefinition/Dao.php | 191 ++++++++++-------- .../Model/ImportDefinition/Listing.php | 15 +- .../Model/ImportDefinition/Listing/Dao.php | 50 +++-- src/DataDefinitionsBundle/Model/Log/Dao.php | 2 +- .../Model/Log/Listing.php | 17 +- .../Model/Log/Listing/Dao.php | 8 +- .../Provider/AbstractFileProvider.php | 4 +- .../Provider/CsvProvider.php | 2 +- .../Provider/XmlProvider.php | 2 +- .../Resources/config/pimcore/config.yml | 8 - .../Resources/config/pimcore/messenger.yml | 18 -- .../config/serializer/Model.Definition.yml | 2 +- .../serializer/Model.ExportDefinition.yml | 9 - .../serializer/Model.ImportDefinition.yml | 9 - .../Resources/config/services.yml | 21 +- .../Resources/config/services/commands.yml | 8 - .../Resources/config/services/forms.yml | 7 +- .../public/pimcore/css/datadefinition.css | 4 +- .../pimcore/js/definition/abstractItem.js | 11 +- .../public/pimcore/js/export/item.js | 10 - .../public/pimcore/js/export/panel.js | 14 -- .../public/pimcore/js/import/item.js | 4 - .../public/pimcore/js/import/panel.js | 13 -- .../pimcore/js/interpreters/typecasting.js | 41 ---- .../js/process_manager/export_contextmenu.js | 160 ++++++++------- .../js/process_manager/export_search.js | 1 + .../Resources/public/pimcore/js/startup.js | 8 +- .../Resources/translations/admin.en.yml | 1 - .../Rules/Model/ImportRule.php | 2 +- src/Kernel.php | 8 +- .../Behat/Context/Domain/PimcoreContext.php | 4 +- .../Behat/Context/Hook/IMSetupContext.php | 34 +--- .../Behat/Context/Hook/PimcoreDaoContext.php | 28 +-- .../Context/Setup/PimcoreClassContext.php | 22 +- .../Context/Transform/PimcoreClassContext.php | 6 +- .../Resources/config/profiles/default.yml | 4 +- .../config/services/contexts/hook.yml | 1 - 81 files changed, 628 insertions(+), 1350 deletions(-) create mode 100644 config/migrations.yaml delete mode 100644 src/BehatKernel.php delete mode 100644 src/DataDefinitionsBundle/Command/ImportAsyncCommand.php delete mode 100644 src/DataDefinitionsBundle/Controller/AbstractDefinitionController.php delete mode 100644 src/DataDefinitionsBundle/EventListener/PimcoreSettingsListener.php delete mode 100644 src/DataDefinitionsBundle/EventListener/WriteableListener.php delete mode 100644 src/DataDefinitionsBundle/Form/Type/Interpreter/TypeCastingInterpreterType.php delete mode 100644 src/DataDefinitionsBundle/Importer/AsyncImporterInterface.php delete mode 100644 src/DataDefinitionsBundle/Messenger/ImportRowMessage.php delete mode 100644 src/DataDefinitionsBundle/Messenger/ImportRowMessageHandler.php delete mode 100755 src/DataDefinitionsBundle/Resources/config/pimcore/messenger.yml delete mode 100644 src/DataDefinitionsBundle/Resources/public/pimcore/js/interpreters/typecasting.js diff --git a/.github/workflows/behat.yml b/.github/workflows/behat.yml index 11562840..e2c18e7f 100644 --- a/.github/workflows/behat.yml +++ b/.github/workflows/behat.yml @@ -1,9 +1,9 @@ name: Behat on: push: - branches: [ '4.0' ] + branches: [ master ] pull_request: - branches: [ '4.0' ] + branches: [ master ] jobs: behat: @@ -11,45 +11,41 @@ jobs: env: APP_ENV: "test" IM_SKIP_DB_SETUP: "1" - PIMCORE_TEST_DB_DSN: "mysql://root:root@127.0.0.1:3306/coreshop_test" PIMCORE_INSTALL_ADMIN_USERNAME: "admin" PIMCORE_INSTALL_ADMIN_PASSWORD: "admin" PIMCORE_INSTALL_MYSQL_HOST_SOCKET: "127.0.0.1" PIMCORE_INSTALL_MYSQL_USERNAME: "root" PIMCORE_INSTALL_MYSQL_PASSWORD: "root" - PIMCORE_INSTALL_MYSQL_DATABASE: "coreshop_test" + PIMCORE_INSTALL_MYSQL_DATABASE: "data_defs_test" PIMCORE_INSTALL_MYSQL_PORT: "3306" PIMCORE_KERNEL_CLASS: 'Kernel' PIMCORE_CLASS_DIRECTORY: 'var/tmp/behat/var/classes' - - strategy: - matrix: - php: [ 8.1, 8.2 ] - pimcore: [ ^11.0 ] - dependencies: [ highest ] - exclude: - - php: 8.1 - dependencies: lowest + PIMCORE_WRITE_TARGET_STATICROUTES: 'settings-store' + PIMCORE_TEST_DB_DSN: "mysql://root:root@127.0.0.1:3306/data_defs_test" services: database: - image: "mysql:8" + image: "mariadb:10.5" env: MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: data_defs_test ports: - 3306:3306 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - name: "${{ matrix.pimcore }}, PHP ${{ matrix.php }}, Deps ${{ matrix.dependencies }}" + name: "${{ matrix.pimcore }}, PHP ${{ matrix.php }}" + strategy: + matrix: + php: [ 8.0, 8.1 ] + pimcore: [ ^10.5 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - ini-values: display_errors=On, display_startup_errors=On, error_reporting=32767 extensions: intl, gd, simpleXML, dom, exif, fileinfo, iconv, mbstring, mysqli, pdo_mysql, zip, zlib - name: Check PHP Version @@ -61,26 +57,26 @@ jobs: - name: Get composer cache directory id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache composer dependencies - uses: actions/cache@v3 + uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - - if: matrix.dependencies == 'highest' - name: Install dependencies highest - run: | - composer req pimcore/pimcore:${{ matrix.pimcore }} --no-interaction --no-scripts --no-update - composer update --no-progress --prefer-dist --optimize-autoloader + - name: Cache composer dependencies + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- - - if: matrix.dependencies == 'lowest' - name: Install dependencies lowest + - name: Install dependencies highest run: | - composer req pimcore/pimcore:${{ matrix.pimcore }} --no-interaction --no-scripts --no-update - composer update --no-progress --prefer-dist --optimize-autoloader --prefer-lowest + composer req guzzlehttp/psr7 pimcore/pimcore:${{ matrix.pimcore }} --no-interaction --no-scripts --no-update + composer update --no-progress --prefer-dist --optimize-autoloader - name: Cache clear run: bin/console cache:clear @@ -89,7 +85,7 @@ jobs: run: bin/console assets:install --symlink - name: Install Pimcore - run: PIMCORE_KERNEL_CLASS=Kernel vendor/bin/pimcore-install --env=test --skip-database-config + run: PIMCORE_KERNEL_CLASS=Kernel vendor/bin/pimcore-install --ignore-existing-config --env=test --skip-database-config - name: Install DataDefinitions run: bin/console pimcore:bundle:install DataDefinitionsBundle diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index f25dff49..54d4d198 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -1,40 +1,41 @@ name: Static Tests (Lint, Stan) on: push: - branches: [ '4.0' ] + branches: [ master ] pull_request: - branches: [ '4.0' ] + branches: [ master ] jobs: lint: runs-on: ubuntu-latest env: APP_ENV: "test" - PIMCORE_TEST_DB_DSN: "mysql://root:root@127.0.0.1:3306/coreshop_test" + PIMCORE_TEST_DB_DSN: "mysql://root:root@127.0.0.1:3306/data_defs_test" strategy: matrix: - php: [ 8.1, 8.2 ] - pimcore: [ ^11.0 ] - dependencies: [ highest ] + php: [ 8.0, 8.1 ] + pimcore: [ ^10.5 ] + database: [ 'mysql:8.0' ] + dependencies: [ highest, lowest ] exclude: - php: 8.1 dependencies: lowest services: database: - image: "mysql:8" + image: "${{ matrix.database }}" env: MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: coreshop_test + MYSQL_DATABASE: data_defs_test ports: - 3306:3306 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - name: "${{ matrix.pimcore }}, PHP ${{ matrix.php }}, Deps ${{ matrix.dependencies }}" + name: "${{ matrix.pimcore }}, PHP ${{ matrix.php }}, DB ${{ matrix.database }}, Deps ${{ matrix.dependencies }}" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -48,10 +49,10 @@ jobs: - name: Get composer cache directory id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache composer dependencies - uses: actions/cache@v3 + uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -60,13 +61,13 @@ jobs: - if: matrix.dependencies == 'highest' name: Install dependencies highest run: | - composer req pimcore/pimcore:${{ matrix.pimcore }} --no-interaction --no-scripts --no-update + composer req guzzlehttp/psr7 pimcore/pimcore:${{ matrix.pimcore }} --no-interaction --no-scripts --no-update composer update --no-progress --prefer-dist --optimize-autoloader - if: matrix.dependencies == 'lowest' name: Install dependencies lowest run: | - composer req pimcore/pimcore:${{ matrix.pimcore }} --no-interaction --no-scripts --no-update + composer req guzzlehttp/psr7 pimcore/pimcore:${{ matrix.pimcore }} --no-interaction --no-scripts --no-update composer update --no-progress --prefer-dist --optimize-autoloader --prefer-lowest - name: Validate YAML diff --git a/behat-bootstrap.php b/behat-bootstrap.php index db37a032..5a946700 100755 --- a/behat-bootstrap.php +++ b/behat-bootstrap.php @@ -1,20 +1,10 @@ =8.0", "ext-json": "*", "box/spout": "^3.0", - "coreshop/pimcore-bundle": "^4.0", - "coreshop/resource-bundle": "^4.0", - "coreshop/rule-bundle": "^4.0", + "coreshop/pimcore-bundle": "^3.0", + "coreshop/resource-bundle": "^3.0", + "coreshop/rule-bundle": "^3.0", "jms/serializer": "^3.17.1", "league/csv": "^9.7", "nyholm/psr7": "^1.5", - "pimcore/admin-ui-classic-bundle": "^1.0", - "pimcore/pimcore": "^11.0", + "pimcore/pimcore": "^10.5", "psr/http-client-implementation": "^1.0", - "psr/http-factory-implementation": "^1.0", - "symfony/dotenv": "^6.3", - "symfony/http-client": "^6.3" + "psr/http-factory-implementation": "^1.0" }, "require-dev": { "roave/security-advisories": "dev-latest", @@ -68,11 +65,7 @@ }, "autoload-dev": { "psr-4": { - "Wvision\\Bundle\\DataDefinitionsBundle\\Behat\\": "tests/DataDefinitionsBundle/Behat", - "Pimcore\\Model\\DataObject\\": [ - "var/classes/DataObject", - "var/tmp/behat/var/classes/DataObject" - ] + "Wvision\\Bundle\\DataDefinitionsBundle\\Behat\\": "tests/DataDefinitionsBundle/Behat" }, "classmap": [ "src/Kernel.php" diff --git a/config/config.yaml b/config/config.yaml index d84a1e5f..3df4a70d 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,5 +1,6 @@ imports: - { resource: services.yaml } + - { resource: migrations.yaml } - { resource: system.yml } - { resource: 'local/' } diff --git a/config/migrations.yaml b/config/migrations.yaml new file mode 100644 index 00000000..9617ac97 --- /dev/null +++ b/config/migrations.yaml @@ -0,0 +1,19 @@ +doctrine_migrations: + connection: default + migrations_paths: + 'Pimcore\Bundle\CoreBundle\Migrations': '@PimcoreCoreBundle/Migrations' + storage: + table_storage: + table_name: 'migration_versions' + version_column_name: 'version' + version_column_length: 1024 + executed_at_column_name: 'executed_at' + execution_time_column_name: 'execution_time' + all_or_nothing: false + check_database_platform: false + factories: + 'Doctrine\Migrations\MigrationsRepository': 'Pimcore\Migrations\FilteredMigrationsRepository' + 'Doctrine\Migrations\Metadata\Storage\MetadataStorage': 'Pimcore\Migrations\FilteredTableMetadataStorage' + + + diff --git a/config/packages/security.yaml b/config/packages/security.yaml index df3e2daf..9675d5a6 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -1,9 +1,7 @@ security: - enable_authenticator_manager: true - providers: pimcore_admin: - id: Pimcore\Security\User\UserProvider + id: Pimcore\Bundle\AdminBundle\Security\User\UserProvider firewalls: dev: @@ -11,25 +9,46 @@ security: security: false # Pimcore WebDAV HTTP basic // DO NOT CHANGE! - pimcore_webdav: - pattern: ^/asset/webdav + pimcore_admin_webdav: + pattern: ^/admin/asset/webdav provider: pimcore_admin http_basic: ~ - # Pimcore Admin Bundle firewall - pimcore_admin: '%pimcore_admin_bundle.firewall_settings%' + # Pimcore admin form login // DO NOT CHANGE! + pimcore_admin: + anonymous: ~ + pattern: ^/admin(/.*)?$ + # admin firewall is stateless as we open the admin + # session on demand for non-blocking parallel requests + stateless: true + provider: pimcore_admin + logout: + path: /admin/logout + target: /admin/login + success_handler: Pimcore\Bundle\AdminBundle\Security\LogoutSuccessHandler + guard: + entry_point: Pimcore\Bundle\AdminBundle\Security\Guard\AdminAuthenticator + authenticators: + - Pimcore\Bundle\AdminBundle\Security\Guard\AdminAuthenticator + two_factor: + auth_form_path: /admin/login/2fa # Path or route name of the two-factor form + check_path: /admin/login/2fa-verify # Path or route name of the two-factor code check + default_target_path: /admin # Where to redirect by default after successful authentication + always_use_default_target_path: false # If it should always redirect to default_target_path + auth_code_parameter_name: _auth_code # Name of the parameter for the two-factor authentication code + trusted_parameter_name: _trusted # Name of the parameter for the trusted device option + multi_factor: false # If ALL active two-factor methods need to be fulfilled (multi-factor authentication) + access_control: # Pimcore admin ACl // DO NOT CHANGE! - - { path: ^/admin/settings/display-custom-logo, roles: PUBLIC_ACCESS } - - { path: ^/admin/login/2fa-verify, roles: IS_AUTHENTICATED_2FA_IN_PROGRESS } - - { path: ^/admin/login/2fa-setup, roles: ROLE_PIMCORE_USER } - - { path: ^/admin/login/2fa, roles: IS_AUTHENTICATED_2FA_IN_PROGRESS } - - { path: ^/admin/login$, roles: PUBLIC_ACCESS } - - { path: ^/admin/login/(login|lostpassword|deeplink|csrf-token)$, roles: PUBLIC_ACCESS } + - { path: ^/admin/settings/display-custom-logo, roles: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/admin/login/2fa-verify, roles: IS_AUTHENTICATED_2FA_IN_PROGRESS} + - { path: ^/admin/login/2fa, roles: IS_AUTHENTICATED_2FA_IN_PROGRESS} + - { path: ^/admin/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/admin/login/(login|lostpassword|deeplink|csrf-token)$, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/admin, roles: ROLE_PIMCORE_USER } - - { path: ^/asset/webdav, roles: ROLE_PIMCORE_USER } role_hierarchy: # Pimcore admin // DO NOT CHANGE! - ROLE_PIMCORE_ADMIN: [ROLE_PIMCORE_USER] \ No newline at end of file + ROLE_PIMCORE_ADMIN: [ROLE_PIMCORE_USER] diff --git a/config/packages/test/config.yaml b/config/packages/test/config.yaml index b6c73d1e..f7eb973f 100644 --- a/config/packages/test/config.yaml +++ b/config/packages/test/config.yaml @@ -21,12 +21,3 @@ parameters: framework: session: handler_id: 'Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler' - -data_definitions: - config_location: - import_definitions: - write_target: - type: settings-store - export_definitions: - write_target: - type: settings-store \ No newline at end of file diff --git a/config/routes.yaml b/config/routes.yaml index b516051b..3c1894dd 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -1,2 +1,2 @@ _pimcore: - resource: "@PimcoreCoreBundle/config/routing.yaml" + resource: "@PimcoreCoreBundle/Resources/config/routing.yml" diff --git a/config/routes/dev/routes.yaml b/config/routes/dev/routes.yaml index 50d25c70..8ee148fe 100644 --- a/config/routes/dev/routes.yaml +++ b/config/routes/dev/routes.yaml @@ -1,2 +1,3 @@ _pimcore_dev: - resource: "@PimcoreCoreBundle/config/routing_dev.yaml" \ No newline at end of file + resource: "@PimcoreCoreBundle/Resources/config/routing_dev.yml" + diff --git a/config/system.yml b/config/system.yml index b7a4b2b8..5995ca1d 100644 --- a/config/system.yml +++ b/config/system.yml @@ -12,6 +12,7 @@ pimcore: default_language: '' disable_usage_statistics: false debug_admin_translations: false + instance_identifier: '' documents: versions: days: null @@ -31,6 +32,14 @@ pimcore: steps: 10 icc_rgb_profile: '' icc_cmyk_profile: '' + hide_edit_image: false + disable_tree_preview: false + services: + google: + client_id: '' + email: '' + simple_api_key: '' + browser_api_key: '' httpclient: adapter: Socket proxy_host: '' @@ -44,6 +53,14 @@ pimcore: return: name: pimcore email: pimcore@example.com + newsletter: + sender: + name: '' + email: '' + return: + name: '' + email: '' + use_specific: true applicationlog: mail_notification: send_log_summary: false diff --git a/features/cleaner/deleter.feature b/features/cleaner/deleter.feature index 3483f6b2..30a680b3 100644 --- a/features/cleaner/deleter.feature +++ b/features/cleaner/deleter.feature @@ -16,7 +16,7 @@ Feature: Adding a import with a cleaner And the import-definitions mapping is: | fromColumn | toColumn | primary | | name | name | true | - | published | published | false | + | published | o_published | false | And there is a file test.csv with content: """ name,published diff --git a/features/cleaner/none.feature b/features/cleaner/none.feature index 28aebe4b..673c7b35 100644 --- a/features/cleaner/none.feature +++ b/features/cleaner/none.feature @@ -16,7 +16,7 @@ Feature: Adding a import with a cleaner And the import-definitions mapping is: | fromColumn | toColumn | primary | | name | name | true | - | published | published | false | + | published | o_published | false | And there is a file test.csv with content: """ name,published diff --git a/features/cleaner/unpublisher.feature b/features/cleaner/unpublisher.feature index b4838575..e9921243 100644 --- a/features/cleaner/unpublisher.feature +++ b/features/cleaner/unpublisher.feature @@ -16,7 +16,7 @@ Feature: Adding a import with a cleaner And the import-definitions mapping is: | fromColumn | toColumn | primary | | name | name | true | - | published | published | false | + | published | o_published | false | And there is a file test.csv with content: """ name,published diff --git a/src/BehatKernel.php b/src/BehatKernel.php deleted file mode 100644 index 4c78db11..00000000 --- a/src/BehatKernel.php +++ /dev/null @@ -1,32 +0,0 @@ -addBundle(new \Wvision\Bundle\DataDefinitionsBundle\DataDefinitionsBundle()); - $collection->addBundle(new \FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle()); - } - - public function boot(): void - { - parent::boot(); - - \Pimcore::setKernel($this); - } -} diff --git a/src/DataDefinitionsBundle/Command/ExportCommand.php b/src/DataDefinitionsBundle/Command/ExportCommand.php index dbe1d666..5cb1c0d3 100644 --- a/src/DataDefinitionsBundle/Command/ExportCommand.php +++ b/src/DataDefinitionsBundle/Command/ExportCommand.php @@ -76,23 +76,22 @@ protected function execute(InputInterface $input, OutputInterface $output) $eventDispatcher = $this->eventDispatcher; $params = json_decode($input->getOption('params'), true); - $definition = null; try { - $definition = $this->repository->findByName($input->getOption('definition')); + $definition = $this->repository->find($input->getOption('definition')); } catch (InvalidArgumentException $e) { - - } - - if (!$definition instanceof ExportDefinitionInterface) { - throw new Exception('Export Definition not found'); + $definition = $this->repository->findByName($input->getOption('definition')); } - $progress = null; + $process = null; if (!is_array($params)) { $params = []; } + if (!$definition instanceof ExportDefinitionInterface) { + throw new Exception('Export Definition not found'); + } + $imStatus = function (ExportDefinitionEvent $e) use (&$progress) { if ($progress instanceof ProgressBar) { $progress->setMessage($e->getSubject()); diff --git a/src/DataDefinitionsBundle/Command/ImportAsyncCommand.php b/src/DataDefinitionsBundle/Command/ImportAsyncCommand.php deleted file mode 100644 index ac964c23..00000000 --- a/src/DataDefinitionsBundle/Command/ImportAsyncCommand.php +++ /dev/null @@ -1,87 +0,0 @@ -setName('data-definitions:async-import') - ->setDescription('Run a Data Definition Import Async.') - ->addOption( - 'definition', - 'd', - InputOption::VALUE_REQUIRED, - 'Import Definition ID or Name' - ) - ->addOption( - 'params', - 'p', - InputOption::VALUE_REQUIRED, - 'JSON Encoded Params' - ); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $eventDispatcher = $this->eventDispatcher; - - $params = json_decode($input->getOption('params'), true); - - if (!isset($params['userId'])) { - $params['userId'] = 0; - } - - try { - $definition = $this->repository->find($input->getOption('definition')); - } catch (InvalidArgumentException $e) { - $definition = $this->repository->findByName($input->getOption('definition')); - } - - if (!$definition instanceof ImportDefinitionInterface) { - throw new Exception('Import Definition not found'); - } - - $this->importer->doImportAsync($definition, $params); - - return 0; - } -} diff --git a/src/DataDefinitionsBundle/Command/ImportCommand.php b/src/DataDefinitionsBundle/Command/ImportCommand.php index 2278bf3f..c5f1ee3c 100644 --- a/src/DataDefinitionsBundle/Command/ImportCommand.php +++ b/src/DataDefinitionsBundle/Command/ImportCommand.php @@ -82,22 +82,21 @@ protected function execute(InputInterface $input, OutputInterface $output) $params['userId'] = 0; } - $definition = null; - try { - $definition = $this->repository->findByName($input->getOption('definition')); + $definition = $this->repository->find($input->getOption('definition')); } catch (InvalidArgumentException $e) { - - } - - if (!$definition instanceof ImportDefinitionInterface) { - throw new Exception('Import Definition not found'); + $definition = $this->repository->findByName($input->getOption('definition')); } $progress = null; + $process = null; $countProgress = 0; $startTime = time(); + if (!$definition instanceof ImportDefinitionInterface) { + throw new Exception('Import Definition not found'); + } + $imStatus = function (ImportDefinitionEvent $e) use ($output, &$progress, &$countProgress, $startTime) { if ($progress instanceof ProgressBar) { $progress->setMessage($e->getSubject()); diff --git a/src/DataDefinitionsBundle/Controller/AbstractDefinitionController.php b/src/DataDefinitionsBundle/Controller/AbstractDefinitionController.php deleted file mode 100644 index 4f22d0b2..00000000 --- a/src/DataDefinitionsBundle/Controller/AbstractDefinitionController.php +++ /dev/null @@ -1,41 +0,0 @@ -isGrantedOr403(); - - $resources = $this->findOr404((string) $this->getParameterFromRequest($request, 'id')); - - return $this->viewHandler->handle(['data' => $resources, 'success' => true], ['group' => 'Detailed']); - } -} diff --git a/src/DataDefinitionsBundle/Controller/ExportDefinitionController.php b/src/DataDefinitionsBundle/Controller/ExportDefinitionController.php index 61dcd471..c03ad270 100644 --- a/src/DataDefinitionsBundle/Controller/ExportDefinitionController.php +++ b/src/DataDefinitionsBundle/Controller/ExportDefinitionController.php @@ -31,7 +31,7 @@ use Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinitionInterface; use Wvision\Bundle\DataDefinitionsBundle\Model\ExportMapping\FromColumn; -class ExportDefinitionController extends AbstractDefinitionController +class ExportDefinitionController extends ResourceController { public function getConfigAction(): JsonResponse { @@ -563,37 +563,37 @@ protected function getDbFieldConfiguration(Column $column, $group = 'fields'): F protected function getConfigProviders(): array { - return $this->getParameter('data_definitions.export_providers'); + return $this->container->getParameter('data_definitions.export_providers'); } protected function getConfigInterpreters(): array { - return $this->getParameter('data_definitions.interpreters'); + return $this->container->getParameter('data_definitions.interpreters'); } protected function getConfigRunners(): array { - return $this->getParameter('data_definitions.export_runners'); + return $this->container->getParameter('data_definitions.export_runners'); } protected function getConfigGetters(): array { - return $this->getParameter('data_definitions.getters'); + return $this->container->getParameter('data_definitions.getters'); } protected function getConfigFetchers(): array { - return $this->getParameter('data_definitions.fetchers'); + return $this->container->getParameter('data_definitions.fetchers'); } protected function getImportRuleConditions(): array { - return $this->getParameter('data_definitions.import_rule.conditions'); + return $this->container->getParameter('data_definitions.import_rule.conditions'); } protected function getImportRuleActions(): array { - return $this->getParameter('data_definitions.import_rule.actions'); + return $this->container->getParameter('data_definitions.import_rule.actions'); } protected function getConfigCustomFetchers(): array diff --git a/src/DataDefinitionsBundle/Controller/ImportDefinitionController.php b/src/DataDefinitionsBundle/Controller/ImportDefinitionController.php index 220e31d1..3cde1817 100644 --- a/src/DataDefinitionsBundle/Controller/ImportDefinitionController.php +++ b/src/DataDefinitionsBundle/Controller/ImportDefinitionController.php @@ -16,23 +16,21 @@ namespace Wvision\Bundle\DataDefinitionsBundle\Controller; -use CoreShop\Component\Registry\ServiceRegistryInterface; +use CoreShop\Bundle\ResourceBundle\Controller\ResourceController; use Exception; use Pimcore\Model\DataObject; -use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Contracts\Service\Attribute\SubscribedService; use Wvision\Bundle\DataDefinitionsBundle\Model\ImportDefinitionInterface; use Wvision\Bundle\DataDefinitionsBundle\Model\ImportMapping; use Wvision\Bundle\DataDefinitionsBundle\Model\ImportMapping\FromColumn; use Wvision\Bundle\DataDefinitionsBundle\Service\FieldSelection; use function is_array; -class ImportDefinitionController extends AbstractDefinitionController +class ImportDefinitionController extends ResourceController { public function getConfigAction(): JsonResponse { @@ -70,9 +68,7 @@ public function testDataAction(Request $request): JsonResponse if ($definition instanceof ImportDefinitionInterface) { try { - if ($this->container->get('data_definitions.registry.provider')->get( - $definition->getProvider() - )->testData( + if ($this->get('data_definitions.registry.provider')->get($definition->getProvider())->testData( $definition->getConfiguration() )) { return $this->viewHandler->handle(['success' => true]); @@ -96,7 +92,7 @@ public function getColumnsAction(Request $request): JsonResponse $customFromColumn->setLabel('Custom'); try { - $fromColumns = $this->container->get('data_definitions.registry.provider')->get( + $fromColumns = $this->get('data_definitions.registry.provider')->get( $definition->getProvider() )->getColumns($definition->getConfiguration()); $fromColumns[] = $customFromColumn; @@ -110,7 +106,7 @@ public function getColumnsAction(Request $request): JsonResponse throw new NotFoundHttpException(); } - $toColumns = $this->container->get(FieldSelection::class)->getClassDefinition($classDefinition); + $toColumns = $this->get(FieldSelection::class)->getClassDefinition($classDefinition); $mappings = $definition->getMapping(); $mappingDefinition = []; $fromColumnsResult = []; @@ -267,62 +263,53 @@ public function duplicateAction(Request $request): JsonResponse return $this->viewHandler->handle(['success' => false]); } - public static function getSubscribedServices(): array - { - return parent::getSubscribedServices() + [ - FieldSelection::class, - new SubscribedService('data_definitions.registry.provider', ServiceRegistryInterface::class, attributes: new Autowire(service: 'data_definitions.registry.provider')) - ]; - } - - protected function getConfigProviders(): array { - return $this->getParameter('data_definitions.import_providers'); + return $this->container->getParameter('data_definitions.import_providers'); } protected function getConfigLoaders(): array { - return $this->getParameter('data_definitions.loaders'); + return $this->container->getParameter('data_definitions.loaders'); } protected function getConfigInterpreters(): array { - return $this->getParameter('data_definitions.interpreters'); + return $this->container->getParameter('data_definitions.interpreters'); } protected function getConfigCleaners(): array { - return $this->getParameter('data_definitions.cleaners'); + return $this->container->getParameter('data_definitions.cleaners'); } protected function getConfigSetters(): array { - return $this->getParameter('data_definitions.setters'); + return $this->container->getParameter('data_definitions.setters'); } protected function getConfigFilters(): array { - return $this->getParameter('data_definitions.filters'); + return $this->container->getParameter('data_definitions.filters'); } protected function getConfigRunners(): array { - return $this->getParameter('data_definitions.runners'); + return $this->container->getParameter('data_definitions.runners'); } protected function getConfigPersisters(): array { - return $this->getParameter('data_definitions.persisters'); + return $this->container->getParameter('data_definitions.persisters'); } protected function getImportRuleConditions(): array { - return $this->getParameter('data_definitions.import_rule.conditions'); + return $this->container->getParameter('data_definitions.import_rule.conditions'); } protected function getImportRuleActions(): array { - return $this->getParameter('data_definitions.import_rule.actions'); + return $this->container->getParameter('data_definitions.import_rule.actions'); } } diff --git a/src/DataDefinitionsBundle/Controller/ImportRuleController.php b/src/DataDefinitionsBundle/Controller/ImportRuleController.php index ffa45046..4eb20db7 100644 --- a/src/DataDefinitionsBundle/Controller/ImportRuleController.php +++ b/src/DataDefinitionsBundle/Controller/ImportRuleController.php @@ -16,7 +16,7 @@ namespace Wvision\Bundle\DataDefinitionsBundle\Controller; -use Pimcore\Bundle\AdminBundle\Controller\GDPR\AdminController; +use Pimcore\Bundle\AdminBundle\Controller\AdminController; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\File\UploadedFile; diff --git a/src/DataDefinitionsBundle/DataDefinitionsBundle.php b/src/DataDefinitionsBundle/DataDefinitionsBundle.php index 8202151e..4e5d526a 100644 --- a/src/DataDefinitionsBundle/DataDefinitionsBundle.php +++ b/src/DataDefinitionsBundle/DataDefinitionsBundle.php @@ -20,8 +20,6 @@ use CoreShop\Bundle\ResourceBundle\AbstractResourceBundle; use CoreShop\Bundle\ResourceBundle\CoreShopResourceBundle; use CoreShop\Bundle\RuleBundle\CoreShopRuleBundle; -use Pimcore\Bundle\AdminBundle\PimcoreAdminBundle; -use Pimcore\Bundle\SimpleBackendSearchBundle\PimcoreSimpleBackendSearchBundle; use Pimcore\Extension\Bundle\Installer\InstallerInterface; use Pimcore\Extension\Bundle\PimcoreBundleInterface; use Pimcore\HttpKernel\BundleCollection\BundleCollection; @@ -48,11 +46,6 @@ public static function registerDependentBundles(BundleCollection $collection): v { parent::registerDependentBundles($collection); - $collection->addBundles([ - new PimcoreAdminBundle(), - new PimcoreSimpleBackendSearchBundle() - ]); - $collection->addBundles([ new CoreShopRuleBundle(), ], 3500); @@ -65,9 +58,9 @@ public function getSupportedDrivers(): array ]; } - public function build(ContainerBuilder $container): void + public function build(ContainerBuilder $builder): void { - parent::build($container); + parent::build($builder); $builder->addCompilerPass(new CleanerRegistryCompilerPass()); $builder->addCompilerPass(new FilterRegistryCompilerPass()); diff --git a/src/DataDefinitionsBundle/DependencyInjection/Configuration.php b/src/DataDefinitionsBundle/DependencyInjection/Configuration.php index d9044e6f..27a52a8f 100644 --- a/src/DataDefinitionsBundle/DependencyInjection/Configuration.php +++ b/src/DataDefinitionsBundle/DependencyInjection/Configuration.php @@ -18,8 +18,6 @@ use CoreShop\Bundle\ResourceBundle\CoreShopResourceBundle; use CoreShop\Component\Resource\Factory\Factory; -use Pimcore\Bundle\CoreBundle\DependencyInjection\ConfigurationHelper; -use Pimcore\Config\LocationAwareConfigRepository; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -40,97 +38,12 @@ public function getConfigTreeBuilder(): TreeBuilder $treeBuilder = new TreeBuilder('wvision_data_definitions'); $rootNode = $treeBuilder->getRootNode(); - ConfigurationHelper::addConfigLocationWithWriteTargetNodes($rootNode, [ - 'import_definitions' => '/var/config/import-definitions', - 'export_definitions' => '/var/config/export-definitions' - ]); - $rootNode ->children() ->scalarNode('driver')->defaultValue(CoreShopResourceBundle::DRIVER_PIMCORE)->end() ->integerNode('gc_cycle')->defaultValue(50)->end() ->end(); - $rootNode - ->children() - ->arrayNode('import_definitions') - ->normalizeKeys(false) - ->prototype('array') - ->children() - ->scalarNode('name')->end() - ->scalarNode('provider')->end() - ->scalarNode('class')->end() - ->scalarNode('runner')->end() - ->booleanNode('stopOnException')->end() - ->scalarNode('failureNotificationDocument')->end() - ->scalarNode('successNotificationDocument')->end() - ->scalarNode('loader')->end() - ->scalarNode('objectPath')->end() - ->scalarNode('cleaner')->end() - ->scalarNode('key')->end() - ->scalarNode('filter')->end() - ->booleanNode('renameExistingObjects')->end() - ->booleanNode('relocateExistingObjects')->end() - ->booleanNode('skipNewObjects')->end() - ->booleanNode('skipExistingObjects')->end() - ->booleanNode('createVersion')->end() - ->booleanNode('omitMandatoryCheck')->end() - ->booleanNode('forceLoadObject')->end() - ->variableNode('configuration')->end() - ->arrayNode('mapping') - ->prototype('array') - ->children() - ->scalarNode('primaryIdentifier')->end() - ->scalarNode('setter')->end() - ->variableNode('setterConfig')->end() - ->scalarNode('fromColumn')->end() - ->scalarNode('toColumn')->end() - ->scalarNode('interpreter')->end() - ->variableNode('interpreterConfig')->end() - ->end() - ->end() - ->end() - ->integerNode('creationDate')->end() - ->integerNode('modificationDate')->end() - ->end() - ->end() - ->end() - ->arrayNode('export_definitions') - ->normalizeKeys(false) - ->prototype('array') - ->children() - ->scalarNode('name')->end() - ->scalarNode('fetcher')->end() - ->variableNode('fetcherConfig')->end() - ->booleanNode('fetchUnpublished')->end() - ->scalarNode('provider')->end() - ->scalarNode('class')->end() - ->scalarNode('loader')->end() - ->variableNode('configuration')->end() - ->scalarNode('runner')->end() - ->booleanNode('stopOnException')->end() - ->scalarNode('failureNotificationDocument')->end() - ->scalarNode('successNotificationDocument')->end() - ->arrayNode('mapping') - ->prototype('array') - ->children() - ->scalarNode('primaryIdentifier')->end() - ->scalarNode('getter')->end() - ->variableNode('getterConfig')->end() - ->scalarNode('fromColumn')->end() - ->scalarNode('toColumn')->end() - ->scalarNode('interpreter')->end() - ->variableNode('interpreterConfig')->end() - ->end() - ->end() - ->end() - ->integerNode('creationDate')->end() - ->integerNode('modificationDate')->end() - ->end() - ->end() - ->end() - ->end(); - $this->addPimcoreResourcesSection($rootNode); $this->addModelsSection($rootNode); diff --git a/src/DataDefinitionsBundle/DependencyInjection/DataDefinitionsExtension.php b/src/DataDefinitionsBundle/DependencyInjection/DataDefinitionsExtension.php index 13daec58..db948754 100644 --- a/src/DataDefinitionsBundle/DependencyInjection/DataDefinitionsExtension.php +++ b/src/DataDefinitionsBundle/DependencyInjection/DataDefinitionsExtension.php @@ -17,12 +17,9 @@ namespace Wvision\Bundle\DataDefinitionsBundle\DependencyInjection; use CoreShop\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractModelExtension; -use Pimcore\Config\LocationAwareConfigRepository; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Wvision\Bundle\DataDefinitionsBundle\Cleaner\CleanerInterface; use Wvision\Bundle\DataDefinitionsBundle\DependencyInjection\Compiler\CleanerRegistryCompilerPass; use Wvision\Bundle\DataDefinitionsBundle\DependencyInjection\Compiler\CustomFetcherRegistryCompilerPass; @@ -50,7 +47,7 @@ use Wvision\Bundle\DataDefinitionsBundle\Runner\RunnerInterface; use Wvision\Bundle\DataDefinitionsBundle\Setter\SetterInterface; -class DataDefinitionsExtension extends AbstractModelExtension implements PrependExtensionInterface +class DataDefinitionsExtension extends AbstractModelExtension { public function load(array $configs, ContainerBuilder $container) { @@ -131,16 +128,5 @@ public function load(array $configs, ContainerBuilder $container) ->addTag(PersisterRegistryCompilerPass::PERSISTER_TAG); $container->setParameter('data_definitions.gc_cycle', $config['gc_cycle']); - - $container->setParameter('data_definitions.config_location', $config['config_location'] ?? []); - - $container->setParameter('data_definitions.import_definitions', $config['import_definitions']); - $container->setParameter('data_definitions.export_definitions', $config['export_definitions']); - } - - public function prepend(ContainerBuilder $container): void - { - LocationAwareConfigRepository::loadSymfonyConfigFiles($container, 'data_definitions', 'export_definitions'); - LocationAwareConfigRepository::loadSymfonyConfigFiles($container, 'data_definitions', 'import_definitions'); } } diff --git a/src/DataDefinitionsBundle/EventListener/PimcoreSettingsListener.php b/src/DataDefinitionsBundle/EventListener/PimcoreSettingsListener.php deleted file mode 100644 index 9b48546d..00000000 --- a/src/DataDefinitionsBundle/EventListener/PimcoreSettingsListener.php +++ /dev/null @@ -1,29 +0,0 @@ -getSubject(); - - if ($subject instanceof ImportDefinition && !$subject->isWriteable()) { - throw new ConfigWriteException(); - } - - if ($subject instanceof ExportDefinition && !$subject->isWriteable()) { - throw new ConfigWriteException(); - } - } - - public static function getSubscribedEvents() - { - return [ - 'data_definitions.import_definition.pre_save' => 'definitionIsWritable', - 'data_definitions.export_definition.pre_save' => 'definitionIsWritable', - ]; - } -} diff --git a/src/DataDefinitionsBundle/Exporter/Exporter.php b/src/DataDefinitionsBundle/Exporter/Exporter.php index 837bdcaa..e042cb53 100644 --- a/src/DataDefinitionsBundle/Exporter/Exporter.php +++ b/src/DataDefinitionsBundle/Exporter/Exporter.php @@ -21,7 +21,6 @@ use Exception; use InvalidArgumentException; use Pimcore; -use Pimcore\Model\DataObject; use Pimcore\Model\DataObject\Concrete; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -129,9 +128,6 @@ private function runExport( FetcherInterface $fetcher, ExportProviderInterface $provider ) { - $getInheritedValues = DataObject::getGetInheritedValues(); - DataObject::setGetInheritedValues($definition->isEnableInheritance()); - UnpublishedHelper::hideUnpublished( function () use ($definition, $params, $total, $fetcher, $provider, $fetcherContext) { $count = 0; @@ -196,8 +192,6 @@ function () use ($definition, $params, $total, $fetcher, $provider, $fetcherCont }, false === $definition->isFetchUnpublished() ); - - DataObject::setGetInheritedValues($getInheritedValues); } private function exportRow( diff --git a/src/DataDefinitionsBundle/Fetcher/ObjectsFetcher.php b/src/DataDefinitionsBundle/Fetcher/ObjectsFetcher.php index 6c3c6f11..89ebc253 100644 --- a/src/DataDefinitionsBundle/Fetcher/ObjectsFetcher.php +++ b/src/DataDefinitionsBundle/Fetcher/ObjectsFetcher.php @@ -17,8 +17,8 @@ namespace Wvision\Bundle\DataDefinitionsBundle\Fetcher; use InvalidArgumentException; -use Pimcore\Model\DataObject\AbstractObject; use Pimcore\Model\DataObject\ClassDefinition; +use Pimcore\Model\DataObject\Concrete; use Pimcore\Model\DataObject\Listing; use Pimcore\Model\DataObject\AbstractObject; use Wvision\Bundle\DataDefinitionsBundle\Context\FetcherContextInterface; @@ -65,12 +65,12 @@ private function getClassListing(ExportDefinitionInterface $definition, array $p $rootNode = null; $conditionFilters = []; if (isset($params['root'])) { - $rootNode = AbstractObject::getById($params['root']); + $rootNode = Concrete::getById($params['root']); if (null !== $rootNode) { $quotedPath = $list->quote($rootNode->getRealFullPath()); $quotedWildcardPath = $list->quote(str_replace('//', '/', $rootNode->getRealFullPath().'/').'%'); - $conditionFilters[] = '(path = '.$quotedPath.' OR path LIKE '.$quotedWildcardPath.')'; + $conditionFilters[] = '(o_path = '.$quotedPath.' OR o_path LIKE '.$quotedWildcardPath.')'; } } @@ -84,7 +84,7 @@ private function getClassListing(ExportDefinitionInterface $definition, array $p } if (isset($params['only_direct_children']) && $params['only_direct_children'] == 'true' && null !== $rootNode) { - $conditionFilters[] = 'parentId = '.$rootNode->getId(); + $conditionFilters[] = 'o_parentId = '.$rootNode->getId(); } if (isset($params['condition'])) { @@ -103,7 +103,7 @@ private function getClassListing(ExportDefinitionInterface $definition, array $p $list->setCondition(implode(' AND ', $conditionFilters)); // ensure a stable sort across pages - $list->setOrderKey('id'); + $list->setOrderKey('o_id'); $list->setOrder('asc'); return $this->list = $list; diff --git a/src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php b/src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php index 95764898..7ffa436f 100644 --- a/src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php +++ b/src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php @@ -52,7 +52,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ->add('runner', ExportRunnerChoiceType::class) ->add('name', TextType::class) ->add('stopOnException', CheckboxType::class) - ->add('enableInheritance', CheckboxType::class) ->add('fetchUnpublished', CheckboxType::class) ->add('failureNotificationDocument', IntegerType::class) ->add('successNotificationDocument', IntegerType::class) diff --git a/src/DataDefinitionsBundle/Form/Type/Interpreter/TypeCastingInterpreterType.php b/src/DataDefinitionsBundle/Form/Type/Interpreter/TypeCastingInterpreterType.php deleted file mode 100644 index 7922be43..00000000 --- a/src/DataDefinitionsBundle/Form/Type/Interpreter/TypeCastingInterpreterType.php +++ /dev/null @@ -1,38 +0,0 @@ -add('toType', ChoiceType::class, [ - 'choices' => [ - TypeCastingInterpreter::TYPE_INT => TypeCastingInterpreter::TYPE_INT, - TypeCastingInterpreter::TYPE_FLOAT => TypeCastingInterpreter::TYPE_FLOAT, - TypeCastingInterpreter::TYPE_STRING => TypeCastingInterpreter::TYPE_STRING, - TypeCastingInterpreter::TYPE_BOOLEAN => TypeCastingInterpreter::TYPE_BOOLEAN, - ], - ]); - } -} diff --git a/src/DataDefinitionsBundle/Importer/AsyncImporterInterface.php b/src/DataDefinitionsBundle/Importer/AsyncImporterInterface.php deleted file mode 100644 index 8a1cca58..00000000 --- a/src/DataDefinitionsBundle/Importer/AsyncImporterInterface.php +++ /dev/null @@ -1,26 +0,0 @@ -getCreateVersion()) { - Version::enable(); - } else { - Version::disable(); - } - - $dataSet = new ArrayImportDataSet($row); - $runner = null; - $runnerContext = $this->contextFactory->createRunnerContext($definition, $params, $row, $dataSet, null); - - if ($definition->getRunner()) { - /** - * @var RunnerInterface $runner - */ - $runner = $this->runnerRegistry->get($definition->getRunner()); - } - - if ($runner instanceof ImportStartFinishRunnerInterface) { - $runner->startImport($runnerContext); - } - - $filter = null; - $filterType = $definition->getFilter(); - if ($filterType) { - /** - * @var FilterInterface $filter - */ - $filter = $this->filterRegistry->get($filterType); - } - - - $object = $this->importRow( - $definition, - $row, - $dataSet, - $params, - $filter, - $runner - ); - } - - public function doImportAsync(ImportDefinitionInterface $definition, array $params): void - { - /** @var ImportDataSetInterface|array $data */ - $data = $this->getData($definition, $params); - - foreach ($data as $row) { - $this->bus->dispatch( - new ImportRowMessage( - $definition->getId(), - $row, - $params, - ) - ); - } - } - public function doImport(ImportDefinitionInterface $definition, $params): array { $filter = null; @@ -227,10 +164,6 @@ public function doImport(ImportDefinitionInterface $definition, $params): array public function processSuccessfullImport(ImportDefinitionInterface $definition, $params, $objectIds, $exceptions) { - if (!is_int($definition->getSuccessNotificationDocument())) { - return; - } - $this->sendDocument( $definition, Document::getById($definition->getSuccessNotificationDocument()), @@ -242,10 +175,6 @@ public function processSuccessfullImport(ImportDefinitionInterface $definition, public function processFailedImport(ImportDefinitionInterface $definition, $params, $objectIds, $exceptions) { - if (!is_int($definition->getFailureNotificationDocument())) { - return; - } - $this->sendDocument( $definition, Document::getById($definition->getFailureNotificationDocument()), @@ -476,7 +405,7 @@ private function importRow( $params['versionNote'] = sprintf('%s - %s', $definition->getId(), $definition->getName()); $object->setUserModification($params['userId'] ?? 0); - $object->setOmitMandatoryCheck($definition->getOmitMandatoryCheck() ?: false); + $object->setOmitMandatoryCheck($definition->getOmitMandatoryCheck()); $this->saveObject($object, $definition, $params); diff --git a/src/DataDefinitionsBundle/Interpreter/TypeCastingInterpreter.php b/src/DataDefinitionsBundle/Interpreter/TypeCastingInterpreter.php index 94840c79..c803c365 100644 --- a/src/DataDefinitionsBundle/Interpreter/TypeCastingInterpreter.php +++ b/src/DataDefinitionsBundle/Interpreter/TypeCastingInterpreter.php @@ -21,10 +21,9 @@ class TypeCastingInterpreter implements InterpreterInterface { - public const TYPE_INT = 'int'; - public const TYPE_FLOAT = 'float'; - public const TYPE_STRING = 'string'; - public const TYPE_BOOLEAN = 'boolean'; + protected const TYPE_INT = 'int'; + protected const TYPE_STRING = 'string'; + protected const TYPE_BOOLEAN = 'boolean'; public function interpret(InterpreterContextInterface $context): mixed { @@ -33,8 +32,6 @@ public function interpret(InterpreterContextInterface $context): mixed switch ($type) { case static::TYPE_INT: return (int)$context->getValue(); - case static::TYPE_FLOAT: - return (float)$context->getValue(); case static::TYPE_STRING: return (string)$context->getValue(); case static::TYPE_BOOLEAN: diff --git a/src/DataDefinitionsBundle/Messenger/ImportRowMessage.php b/src/DataDefinitionsBundle/Messenger/ImportRowMessage.php deleted file mode 100644 index e821d42a..00000000 --- a/src/DataDefinitionsBundle/Messenger/ImportRowMessage.php +++ /dev/null @@ -1,46 +0,0 @@ -definitionId = $definitionId; - $this->data = $data; - $this->params = $params; - } - - public function getDefinitionId(): int - { - return $this->definitionId; - } - - public function getData(): array - { - return $this->data; - } - - public function getParams(): array - { - return $this->params; - } -} diff --git a/src/DataDefinitionsBundle/Messenger/ImportRowMessageHandler.php b/src/DataDefinitionsBundle/Messenger/ImportRowMessageHandler.php deleted file mode 100644 index 12d8baeb..00000000 --- a/src/DataDefinitionsBundle/Messenger/ImportRowMessageHandler.php +++ /dev/null @@ -1,44 +0,0 @@ -getDefinitionId()); - - if (!$definition) { - throw new \InvalidArgumentException('Invalid definition id'); - } - - $this->importer->doImportRowAsync( - $definition, - $message->getData(), - $message->getParams(), - ); - } -} diff --git a/src/DataDefinitionsBundle/Model/AbstractDataDefinition.php b/src/DataDefinitionsBundle/Model/AbstractDataDefinition.php index b534767d..c55dbb31 100644 --- a/src/DataDefinitionsBundle/Model/AbstractDataDefinition.php +++ b/src/DataDefinitionsBundle/Model/AbstractDataDefinition.php @@ -18,16 +18,10 @@ use Pimcore\Model\AbstractModel; -/** - * @method bool isWriteable() - * @method string getWriteTarget() - * @method void save() - * @method void delete() - */ abstract class AbstractDataDefinition extends AbstractModel implements DataDefinitionInterface { /** - * @var int|string|null + * @var int */ public $id; @@ -86,7 +80,7 @@ abstract class AbstractDataDefinition extends AbstractModel implements DataDefin */ public $successNotificationDocument; - public function getId(): int|string|null + public function getId() { return $this->id; } @@ -134,8 +128,6 @@ public function getName() public function setName($name) { $this->name = $name; - - $this->setId($name); } public function getMapping() diff --git a/src/DataDefinitionsBundle/Model/DataDefinitionInterface.php b/src/DataDefinitionsBundle/Model/DataDefinitionInterface.php index 429ba971..addc6fe6 100644 --- a/src/DataDefinitionsBundle/Model/DataDefinitionInterface.php +++ b/src/DataDefinitionsBundle/Model/DataDefinitionInterface.php @@ -20,6 +20,10 @@ interface DataDefinitionInterface extends ResourceInterface { + /** + * @return mixed + */ + public function getId(); /** * @param int $id diff --git a/src/DataDefinitionsBundle/Model/ExportDefinition.php b/src/DataDefinitionsBundle/Model/ExportDefinition.php index bf11ad7f..052f0199 100644 --- a/src/DataDefinitionsBundle/Model/ExportDefinition.php +++ b/src/DataDefinitionsBundle/Model/ExportDefinition.php @@ -16,16 +16,8 @@ namespace Wvision\Bundle\DataDefinitionsBundle\Model; -/** - * @method ExportDefinition\Dao getDao() - */ class ExportDefinition extends AbstractDataDefinition implements ExportDefinitionInterface { - /** - * @var bool - */ - public $enableInheritance = true; - /** * @var string */ @@ -41,12 +33,7 @@ class ExportDefinition extends AbstractDataDefinition implements ExportDefinitio */ public $fetchUnpublished = false; - public static function getById(string $name) - { - return static::getByName($name); - } - - public static function getByName($id) + public static function getById($id) { $definitionEntry = new ExportDefinition(); $definitionEntry->setId((int)$id); @@ -54,27 +41,11 @@ public static function getByName($id) * @var \Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinition\Dao|\Wvision\Bundle\DataDefinitionsBundle\Model\ImportDefinition\Dao */ $dao = $definitionEntry->getDao(); - $dao->getByName($id); + $dao->getById($id); return $definitionEntry; } - /** - * @param bool $enableInheritance - */ - public function setEnableInheritance(bool $enableInheritance): void - { - $this->enableInheritance = $enableInheritance; - } - - /** - * @return bool - */ - public function isEnableInheritance(): bool - { - return $this->enableInheritance; - } - public function getFetcher() { return $this->fetcher; diff --git a/src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php b/src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php index ef15b1d4..898ae3d5 100644 --- a/src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php +++ b/src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php @@ -24,28 +24,49 @@ use function in_array; use function is_array; -class Dao extends Model\Dao\PimcoreLocationAwareConfigDao +class Dao extends Model\Dao\PhpArrayTable { - private const CONFIG_KEY = 'export_definitions'; - /** * Configure Configuration File */ - public function configure(): void + public function configure() + { + parent::configure(); + $this->setFile('exportdefinitions'); + } + + /** + * Get Configuration By Id + * + * @param null $id + * @throws Exception + */ + public function getById($id = null) { - $config = \Pimcore::getContainer()->getParameter('data_definitions.config_location'); - $definitions = \Pimcore::getContainer()->getParameter('data_definitions.export_definitions'); + if ($id !== null) { + $this->model->setId($id); + } - $storageConfig = $config[self::CONFIG_KEY]; + $data = $this->db->getById($this->model->getId()); - parent::configure([ - 'containerConfig' => $definitions, - 'settingsStoreScope' => 'data_definitions', - 'storageConfig' => $storageConfig, - ]); + if (isset($data['id'])) { + $this->assignVariablesToModel($data); + } else { + throw new InvalidArgumentException( + sprintf( + 'Export Definition with id: %s does not exist', + $this->model->getId() + ) + ); + } } - protected function assignVariablesToModel($data): void + /** + * @param array $data + * @return void + * @throws Exception + */ + protected function assignVariablesToModel($data) { parent::assignVariablesToModel($data); @@ -73,26 +94,27 @@ protected function assignVariablesToModel($data): void * @param null $name * @throws Exception */ - public function getByName(string $id = null): void + public function getByName($name = null) { - if ($id != null) { - $this->model->setName($id); + if ($name !== null) { + $this->model->setName($name); } - $data = $this->getDataByName($this->model->getName()); + $name = $this->model->getName(); - if ($data && $id != null) { - $data['id'] = $id; - } + $data = $this->db->fetchAll(function ($row) use ($name) { + return $row['name'] === $name; + }); - if ($data) { - $this->assignVariablesToModel($data); - $this->model->setName($data['id']); + if ($data[0]['id'] && count($data)) { + $this->assignVariablesToModel($data[0]); } else { - throw new Model\Exception\NotFoundException(sprintf( - 'Thumbnail with ID "%s" does not exist.', - $this->model->getName() - )); + throw new InvalidArgumentException( + sprintf( + 'Definition with name: %s does not exist', + $this->model->getName() + ) + ); } } @@ -109,59 +131,56 @@ public function save() } $this->model->setModificationDate($ts); - $dataRaw = get_object_vars($this->model); - $data = []; - $allowedProperties = [ - 'name', - 'provider', - 'class', - 'configuration', - 'creationDate', - 'modificationDate', - 'mapping', - 'runner', - 'stopOnException', - 'enableInheritance', - 'fetchUnpublished', - 'failureNotificationDocument', - 'successNotificationDocument', - 'fetcher', - 'fetcherConfig', - ]; - - foreach ($dataRaw as $key => $value) { - if (in_array($key, $allowedProperties, true)) { - if ($key === 'providerConfiguration') { - if ($value) { - $data[$key] = get_object_vars($value); - } - } elseif ($key === 'mapping') { - if ($value) { - $data[$key] = array(); - - if (is_array($value)) { - foreach ($value as $map) { - $data[$key][] = get_object_vars($map); + try { + $dataRaw = get_object_vars($this->model); + $data = []; + $allowedProperties = [ + 'id', + 'name', + 'provider', + 'class', + 'configuration', + 'creationDate', + 'modificationDate', + 'mapping', + 'runner', + 'stopOnException', + 'fetchUnpublished', + 'failureNotificationDocument', + 'successNotificationDocument', + 'fetcher', + 'fetcherConfig', + ]; + + foreach ($dataRaw as $key => $value) { + if (in_array($key, $allowedProperties, true)) { + if ($key === 'providerConfiguration') { + if ($value) { + $data[$key] = get_object_vars($value); + } + } elseif ($key === 'mapping') { + if ($value) { + $data[$key] = array(); + + if (is_array($value)) { + foreach ($value as $map) { + $data[$key][] = get_object_vars($map); + } } } + } else { + $data[$key] = $value; } - } else { - $data[$key] = $value; } } + $this->db->insertOrUpdate($data, $this->model->getId()); + } catch (Exception $e) { + throw $e; } - $this->saveData($this->model->getName(), $data); - } - protected function prepareDataStructureForYaml(string $id, mixed $data): mixed - { - return [ - 'data_definitions' => [ - 'export_definitions' => [ - $id => $data, - ], - ], - ]; + if (!$this->model->getId()) { + $this->model->setId($this->db->getLastInsertId()); + } } /** @@ -170,6 +189,6 @@ protected function prepareDataStructureForYaml(string $id, mixed $data): mixed */ public function delete() { - $this->deleteData($this->model->getName()); + $this->db->delete($this->model->getId()); } } diff --git a/src/DataDefinitionsBundle/Model/ExportDefinition/Listing.php b/src/DataDefinitionsBundle/Model/ExportDefinition/Listing.php index 19c8b1e0..fa97d043 100644 --- a/src/DataDefinitionsBundle/Model/ExportDefinition/Listing.php +++ b/src/DataDefinitionsBundle/Model/ExportDefinition/Listing.php @@ -17,21 +17,11 @@ namespace Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinition; use Exception; -use Pimcore\Model\AbstractModel; -use Pimcore\Model\Listing\CallableFilterListingInterface; -use Pimcore\Model\Listing\CallableOrderListingInterface; -use Pimcore\Model\Listing\Traits\FilterListingTrait; -use Pimcore\Model\Listing\Traits\OrderListingTrait; +use Pimcore\Model; use Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinitionInterface; -/** - * @method loadList() - */ -class Listing extends AbstractModel implements CallableFilterListingInterface, CallableOrderListingInterface +class Listing extends Model\Listing\JsonListing { - use FilterListingTrait; - use OrderListingTrait; - /** * Contains the results of the list. * They are all an instance of Configuration. @@ -44,10 +34,10 @@ class Listing extends AbstractModel implements CallableFilterListingInterface, C * @return ExportDefinitionInterface[] * @throws Exception */ - public function getObjects() + public function getObjects(): ?array { if (null === $this->definitions) { - $this->loadList(); + $this->load(); } return $this->definitions; diff --git a/src/DataDefinitionsBundle/Model/ExportDefinition/Listing/Dao.php b/src/DataDefinitionsBundle/Model/ExportDefinition/Listing/Dao.php index 71b22167..315bc1a6 100644 --- a/src/DataDefinitionsBundle/Model/ExportDefinition/Listing/Dao.php +++ b/src/DataDefinitionsBundle/Model/ExportDefinition/Listing/Dao.php @@ -16,31 +16,52 @@ namespace Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinition\Listing; +use Exception; +use Pimcore; use Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinition; use function count; -class Dao extends ExportDefinition\Dao +class Dao extends Pimcore\Model\Dao\PhpArrayTable { - public function loadList(): array + /** + * Configure + */ + public function configure() { - $definitions = []; - foreach ($this->loadIdList() as $name) { - $definitions[] = ExportDefinition::getByName($name); - } + parent::configure(); + $this->setFile('exportdefinitions'); + } - if ($this->model->getFilter()) { - $definitions = array_filter($definitions, $this->model->getFilter()); - } - if ($this->model->getOrder()) { - usort($definitions, $this->model->getOrder()); + /** + * Loads a list of Definitions for the specified parameters, returns an array of Definitions elements. + * + * @return array + * @throws Exception + */ + public function load() + { + $routesData = $this->db->fetchAll($this->model->getFilter(), $this->model->getOrder()); + + $routes = array(); + foreach ($routesData as $routeData) { + $routes[] = ExportDefinition::getById($routeData['id']); } - $this->model->setObjects($definitions); - return $definitions; + $this->model->setObjects($routes); + + return $routes; } - public function getTotalCount(): int + /** + * Get total count + * + * @return int + * @throws Exception + */ + public function getTotalCount() { - return count($this->loadList()); + $data = $this->db->fetchAll($this->model->getFilter(), $this->model->getOrder()); + + return count($data); } } diff --git a/src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php b/src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php index 7239c17e..96dc6f28 100644 --- a/src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php +++ b/src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php @@ -18,16 +18,6 @@ interface ExportDefinitionInterface extends DataDefinitionInterface { - /** - * @param bool $enableInheritance - */ - public function setEnableInheritance(bool $enableInheritance): void; - - /** - * @return bool - */ - public function isEnableInheritance(): bool; - /** * @return mixed */ diff --git a/src/DataDefinitionsBundle/Model/ImportDefinition.php b/src/DataDefinitionsBundle/Model/ImportDefinition.php index 86ec2f14..438f43ba 100644 --- a/src/DataDefinitionsBundle/Model/ImportDefinition.php +++ b/src/DataDefinitionsBundle/Model/ImportDefinition.php @@ -16,9 +16,6 @@ namespace Wvision\Bundle\DataDefinitionsBundle\Model; -/** - * @method ImportDefinition\Dao getDao() - */ class ImportDefinition extends AbstractDataDefinition implements ImportDefinitionInterface { /** @@ -86,12 +83,7 @@ class ImportDefinition extends AbstractDataDefinition implements ImportDefinitio */ public $persister; - public static function getById(string $name) - { - return static::getByName($name); - } - - public static function getByName($id) + public static function getById($id) { $definitionEntry = new ImportDefinition(); $definitionEntry->setId((int)$id); @@ -99,7 +91,7 @@ public static function getByName($id) * @var \Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinition\Dao|\Wvision\Bundle\DataDefinitionsBundle\Model\ImportDefinition\Dao */ $dao = $definitionEntry->getDao(); - $dao->getByName($id); + $dao->getById($id); return $definitionEntry; } diff --git a/src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php b/src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php index e2698ef7..23e965dd 100644 --- a/src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php +++ b/src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php @@ -17,33 +17,56 @@ namespace Wvision\Bundle\DataDefinitionsBundle\Model\ImportDefinition; use Exception; +use InvalidArgumentException; use Pimcore\Model; use Wvision\Bundle\DataDefinitionsBundle\Model\ImportMapping; +use function count; use function in_array; use function is_array; -class Dao extends Model\Dao\PimcoreLocationAwareConfigDao +class Dao extends Model\Dao\PhpArrayTable { - private const CONFIG_KEY = 'import_definitions'; - /** * Configure Configuration File */ - public function configure(): void + public function configure() { - $config = \Pimcore::getContainer()->getParameter('data_definitions.config_location'); - $definitions = \Pimcore::getContainer()->getParameter('data_definitions.import_definitions'); + parent::configure(); + $this->setFile('importdefinitions'); + } - $storageConfig = $config[self::CONFIG_KEY]; + /** + * Get Configuration By Id + * + * @param null $id + * @throws Exception + */ + public function getById($id = null) + { + if ($id !== null) { + $this->model->setId($id); + } + + $data = $this->db->getById($this->model->getId()); - parent::configure([ - 'containerConfig' => $definitions, - 'settingsStoreScope' => 'data_definitions', - 'storageConfig' => $storageConfig, - ]); + if (isset($data['id'])) { + $this->assignVariablesToModel($data); + } else { + throw new InvalidArgumentException( + sprintf( + 'Definition with id: %s does not exist', + $this->model->getId() + ) + ); + } } - protected function assignVariablesToModel($data): void + /** + * @param array $data + * @return void + * @throws Exception + */ + protected function assignVariablesToModel($data) { parent::assignVariablesToModel($data); @@ -71,26 +94,27 @@ protected function assignVariablesToModel($data): void * @param null $name * @throws Exception */ - public function getByName(string $id = null): void + public function getByName($name = null) { - if ($id != null) { - $this->model->setName($id); + if ($name !== null) { + $this->model->setName($name); } - $data = $this->getDataByName($this->model->getName()); + $name = $this->model->getName(); - if ($data && $id != null) { - $data['id'] = $id; - } + $data = $this->db->fetchAll(function ($row) use ($name) { + return $row['name'] === $name; + }); - if ($data) { - $this->assignVariablesToModel($data); - $this->model->setName($data['id']); + if (isset($data[0]['id']) && count($data)) { + $this->assignVariablesToModel($data[0]); } else { - throw new Model\Exception\NotFoundException(sprintf( - 'Thumbnail with ID "%s" does not exist.', - $this->model->getName() - )); + throw new InvalidArgumentException( + sprintf( + 'Definition with name: %s does not exist', + $this->model->getName() + ) + ); } } @@ -107,70 +131,67 @@ public function save() } $this->model->setModificationDate($ts); - $dataRaw = get_object_vars($this->model); - $data = []; - $allowedProperties = [ - 'name', - 'provider', - 'class', - 'configuration', - 'creationDate', - 'modificationDate', - 'mapping', - 'objectPath', - 'cleaner', - 'key', - 'renameExistingObjects', - 'relocateExistingObjects', - 'filter', - 'runner', - 'createVersion', - 'stopOnException', - 'omitMandatoryCheck', - 'failureNotificationDocument', - 'successNotificationDocument', - 'skipExistingObjects', - 'skipNewObjects', - 'forceLoadObject', - 'loader', - 'fetcher', - 'persister', - ]; - - foreach ($dataRaw as $key => $value) { - if (in_array($key, $allowedProperties, true)) { - if ($key === 'providerConfiguration') { - if ($value) { - $data[$key] = get_object_vars($value); - } - } elseif ($key === 'mapping') { - if ($value) { - $data[$key] = array(); - - if (is_array($value)) { - foreach ($value as $map) { - $data[$key][] = get_object_vars($map); + try { + $dataRaw = get_object_vars($this->model); + $data = []; + $allowedProperties = [ + 'id', + 'name', + 'provider', + 'class', + 'configuration', + 'creationDate', + 'modificationDate', + 'mapping', + 'objectPath', + 'cleaner', + 'key', + 'renameExistingObjects', + 'relocateExistingObjects', + 'filter', + 'runner', + 'createVersion', + 'stopOnException', + 'omitMandatoryCheck', + 'failureNotificationDocument', + 'successNotificationDocument', + 'skipExistingObjects', + 'skipNewObjects', + 'forceLoadObject', + 'loader', + 'fetcher', + ]; + + foreach ($dataRaw as $key => $value) { + if (in_array($key, $allowedProperties, true)) { + if ($key === 'providerConfiguration') { + if ($value) { + $data[$key] = get_object_vars($value); + } + } elseif ($key === 'mapping') { + if ($value) { + $data[$key] = array(); + + if (is_array($value)) { + foreach ($value as $map) { + $data[$key][] = get_object_vars($map); + } } } + } else { + $data[$key] = $value; } - } else { - $data[$key] = $value; } } - } - $this->saveData($this->model->getName(), $data); - } + $this->db->insertOrUpdate($data, $this->model->getId()); + } catch (Exception $e) { + throw $e; + } - protected function prepareDataStructureForYaml(string $id, mixed $data): mixed - { - return [ - 'data_definitions' => [ - 'import_definitions' => [ - $id => $data, - ], - ], - ]; + if (!$this->model->getId()) { + $this->model->setId($this->db->getLastInsertId()); + } } /** @@ -179,6 +200,6 @@ protected function prepareDataStructureForYaml(string $id, mixed $data): mixed */ public function delete() { - $this->deleteData($this->model->getName()); + $this->db->delete($this->model->getId()); } } diff --git a/src/DataDefinitionsBundle/Model/ImportDefinition/Listing.php b/src/DataDefinitionsBundle/Model/ImportDefinition/Listing.php index cbec7d43..fe5abf2b 100644 --- a/src/DataDefinitionsBundle/Model/ImportDefinition/Listing.php +++ b/src/DataDefinitionsBundle/Model/ImportDefinition/Listing.php @@ -18,21 +18,10 @@ use Exception; use Pimcore\Model; -use Pimcore\Model\AbstractModel; -use Pimcore\Model\Listing\CallableFilterListingInterface; -use Pimcore\Model\Listing\CallableOrderListingInterface; -use Pimcore\Model\Listing\Traits\FilterListingTrait; -use Pimcore\Model\Listing\Traits\OrderListingTrait; use Wvision\Bundle\DataDefinitionsBundle\Model\ImportDefinitionInterface; -/** - * @method loadList() - */ -class Listing extends AbstractModel implements CallableFilterListingInterface, CallableOrderListingInterface +class Listing extends Model\Listing\JsonListing { - use FilterListingTrait; - use OrderListingTrait; - /** * Contains the results of the list. * They are all an instance of Configuration. @@ -48,7 +37,7 @@ class Listing extends AbstractModel implements CallableFilterListingInterface, C public function getObjects() { if (null === $this->definitions) { - $this->loadList(); + $this->load(); } return $this->definitions; diff --git a/src/DataDefinitionsBundle/Model/ImportDefinition/Listing/Dao.php b/src/DataDefinitionsBundle/Model/ImportDefinition/Listing/Dao.php index 02e5b73b..c587dd33 100644 --- a/src/DataDefinitionsBundle/Model/ImportDefinition/Listing/Dao.php +++ b/src/DataDefinitionsBundle/Model/ImportDefinition/Listing/Dao.php @@ -18,32 +18,50 @@ use Exception; use Pimcore; -use Pimcore\Bundle\StaticRoutesBundle\Model\Staticroute; use Wvision\Bundle\DataDefinitionsBundle\Model\ImportDefinition; use function count; -class Dao extends ImportDefinition\Dao +class Dao extends Pimcore\Model\Dao\PhpArrayTable { - public function loadList(): array + /** + * Configure + */ + public function configure() { - $definitions = []; - foreach ($this->loadIdList() as $name) { - $definitions[] = ImportDefinition::getByName($name); - } + parent::configure(); + $this->setFile('importdefinitions'); + } - if ($this->model->getFilter()) { - $definitions = array_filter($definitions, $this->model->getFilter()); - } - if ($this->model->getOrder()) { - usort($definitions, $this->model->getOrder()); + /** + * Loads a list of Definitions for the specified parameters, returns an array of Definitions elements. + * + * @return array + * @throws Exception + */ + public function load() + { + $routesData = $this->db->fetchAll($this->model->getFilter(), $this->model->getOrder()); + + $routes = array(); + foreach ($routesData as $routeData) { + $routes[] = ImportDefinition::getById($routeData['id']); } - $this->model->setObjects($definitions); - return $definitions; + $this->model->setObjects($routes); + + return $routes; } - public function getTotalCount(): int + /** + * Get total count + * + * @return int + * @throws Exception + */ + public function getTotalCount() { - return count($this->loadList()); + $data = $this->db->fetchAll($this->model->getFilter(), $this->model->getOrder()); + + return count($data); } } diff --git a/src/DataDefinitionsBundle/Model/Log/Dao.php b/src/DataDefinitionsBundle/Model/Log/Dao.php index 596ec91d..e1e35e91 100644 --- a/src/DataDefinitionsBundle/Model/Log/Dao.php +++ b/src/DataDefinitionsBundle/Model/Log/Dao.php @@ -40,7 +40,7 @@ public function getById($id = null) $this->model->setId($id); } - $data = $this->db->fetchAssociative('SELECT * FROM '.$this->tableName.' WHERE id = ?', [$this->model->getId()]); + $data = $this->db->fetchRow('SELECT * FROM '.$this->tableName.' WHERE id = ?', $this->model->getId()); if (!$data['id']) { throw new InvalidArgumentException(sprintf('Object with the ID %s does not exist', $this->model->getId())); diff --git a/src/DataDefinitionsBundle/Model/Log/Listing.php b/src/DataDefinitionsBundle/Model/Log/Listing.php index eef5296b..52f06ee9 100644 --- a/src/DataDefinitionsBundle/Model/Log/Listing.php +++ b/src/DataDefinitionsBundle/Model/Log/Listing.php @@ -24,7 +24,12 @@ class Listing extends Model\Listing\AbstractListing implements PaginateListingInterface { - public ?array $data; + /** + * List of Logs. + * + * @var array + */ + public $data; /** * @var string @@ -43,7 +48,7 @@ class Listing extends Model\Listing\AbstractListing implements PaginateListingIn * * @return bool */ - public function isValidOrderKey($key): bool + public function isValidOrderKey($key) { return in_array($key, $this->validOrderKeys, true); } @@ -87,10 +92,10 @@ public function count(): int * * @param int $offset * @param int $itemCountPerPage - * @return array + * @return mixed * @throws Exception */ - public function getItems($offset, $itemCountPerPage): array + public function getItems($offset, $itemCountPerPage) { $this->setOffset($offset); $this->setLimit($itemCountPerPage); @@ -159,10 +164,10 @@ public function current(): mixed /** * Key * - * @return int|string|null + * @return mixed * @throws Exception */ - public function key(): int|string|null + public function key(): mixed { $this->getData(); diff --git a/src/DataDefinitionsBundle/Model/Log/Listing/Dao.php b/src/DataDefinitionsBundle/Model/Log/Listing/Dao.php index 3d15e660..ff77c639 100644 --- a/src/DataDefinitionsBundle/Model/Log/Listing/Dao.php +++ b/src/DataDefinitionsBundle/Model/Log/Listing/Dao.php @@ -49,7 +49,7 @@ protected function getTableName() * @return Log[] * @throws Exception */ - public function load(): array + public function load() { // load id's $list = $this->loadIdList(); @@ -85,7 +85,7 @@ public function getQueryBuilder(...$columns): DoctrineQueryBuilder public function loadIdList() { $queryBuilder = $this->getQueryBuilder(['id']); - $assetIds = $this->db->fetchFirstColumn( + $assetIds = $this->db->fetchCol( (string)$queryBuilder, $this->model->getConditionVariables(), $this->model->getConditionVariableTypes() @@ -105,7 +105,7 @@ public function getCount(): int { return (int)$this->db->fetchOne( 'SELECT COUNT(*) as amount FROM '.$this->getTableName().$this->getCondition().$this->getOffsetLimit(), - [$this->model->getConditionVariables()] + $this->model->getConditionVariables() ); } @@ -119,7 +119,7 @@ public function getTotalCount(): int { return (int)$this->db->fetchOne( 'SELECT COUNT(*) as amount FROM '.$this->getTableName().$this->getCondition(), - [$this->model->getConditionVariables()] + $this->model->getConditionVariables() ); } } diff --git a/src/DataDefinitionsBundle/Provider/AbstractFileProvider.php b/src/DataDefinitionsBundle/Provider/AbstractFileProvider.php index 4454f059..4677cb00 100644 --- a/src/DataDefinitionsBundle/Provider/AbstractFileProvider.php +++ b/src/DataDefinitionsBundle/Provider/AbstractFileProvider.php @@ -67,11 +67,11 @@ protected function createTemporaryFileFromStream($stream) { if (is_string($stream)) { $src = fopen($stream, 'rb'); - $fileExtension = pathinfo($stream, PATHINFO_EXTENSION); + $fileExtension = File::getFileExtension($stream); } else { $src = $stream; $streamMeta = stream_get_meta_data($src); - $fileExtension = pathinfo($streamMeta['uri'], PATHINFO_EXTENSION); + $fileExtension = File::getFileExtension($streamMeta['uri']); } $tmpFilePath = File::getLocalTempFilePath($fileExtension); diff --git a/src/DataDefinitionsBundle/Provider/CsvProvider.php b/src/DataDefinitionsBundle/Provider/CsvProvider.php index 6ee5df9c..ad1adcbd 100644 --- a/src/DataDefinitionsBundle/Provider/CsvProvider.php +++ b/src/DataDefinitionsBundle/Provider/CsvProvider.php @@ -52,7 +52,7 @@ public function getColumns(array $configuration): array if (count($rows) > 0) { $headerRow = $rows[0]; - $headers = str_getcsv($headerRow, $delimiter ?? ',', $enclosure ?: chr(8)); + $headers = str_getcsv($headerRow, $delimiter, $enclosure ?: chr(8)); if (count($headers) > 0) { //First line are the headers diff --git a/src/DataDefinitionsBundle/Provider/XmlProvider.php b/src/DataDefinitionsBundle/Provider/XmlProvider.php index 92f679dd..360903d8 100755 --- a/src/DataDefinitionsBundle/Provider/XmlProvider.php +++ b/src/DataDefinitionsBundle/Provider/XmlProvider.php @@ -135,7 +135,7 @@ public function exportData(array $configuration, ExportDefinitionInterface $defi throw new RuntimeException(sprintf('Passed XSLT file "%1$s" not found', $path)); } - $extension = pathinfo($configuration['xsltPath'], PATHINFO_EXTENSION); + $extension = File::getFileExtension($configuration['xsltPath']); $workingPath = File::getLocalTempFilePath($extension); file_put_contents($workingPath, $storage->read($path)); diff --git a/src/DataDefinitionsBundle/Resources/config/pimcore/config.yml b/src/DataDefinitionsBundle/Resources/config/pimcore/config.yml index 65440c89..16f5c299 100644 --- a/src/DataDefinitionsBundle/Resources/config/pimcore/config.yml +++ b/src/DataDefinitionsBundle/Resources/config/pimcore/config.yml @@ -1,6 +1,3 @@ -imports: - - { resource: messenger.yml } - jms_serializer: metadata: directories: @@ -56,7 +53,6 @@ data_definitions: interpreter_twig: '/bundles/datadefinitions/pimcore/js/interpreters/twig.js' interpreter_carbon: '/bundles/datadefinitions/pimcore/js/interpreters/carbon.js' interpreter_metadata: '/bundles/datadefinitions/pimcore/js/interpreters/metadata.js' - interpreter_typecasting: '/bundles/datadefinitions/pimcore/js/interpreters/typecasting.js' setter_abstract: '/bundles/datadefinitions/pimcore/js/setters/abstract.js' setter_fieldcollection: '/bundles/datadefinitions/pimcore/js/setters/fieldcollection.js' setter_objectbrick: '/bundles/datadefinitions/pimcore/js/setters/objectbrick.js' @@ -79,7 +75,3 @@ data_definitions: import_rules_action_object: '/bundles/datadefinitions/pimcore/js/import_rule/actions/object.js' css: data_definition: '/bundles/datadefinitions/pimcore/css/datadefinition.css' - -framework: - http_client: - enabled: true \ No newline at end of file diff --git a/src/DataDefinitionsBundle/Resources/config/pimcore/messenger.yml b/src/DataDefinitionsBundle/Resources/config/pimcore/messenger.yml deleted file mode 100755 index fe0ff6cd..00000000 --- a/src/DataDefinitionsBundle/Resources/config/pimcore/messenger.yml +++ /dev/null @@ -1,18 +0,0 @@ -framework: - messenger: - transports: - data_definitions_import: - dsn: "doctrine://default?queue_name=data_definitions_import" - failure_transport: data_definitions_import_failed - retry_strategy: - max_retries: 5 - delay: 300000 - multiplier: 2 - # we store failed messages here for admins to manually review them later - data_definitions_import_failed: - dsn: "doctrine://default?queue_name=data_definitions_import_failed" - retry_strategy: - max_retries: 0 - - routing: - 'Wvision\Bundle\DataDefinitionsBundle\Messenger\ImportRowMessage': data_definitions_import \ No newline at end of file diff --git a/src/DataDefinitionsBundle/Resources/config/serializer/Model.Definition.yml b/src/DataDefinitionsBundle/Resources/config/serializer/Model.Definition.yml index f87cd6bb..c7391ba6 100755 --- a/src/DataDefinitionsBundle/Resources/config/serializer/Model.Definition.yml +++ b/src/DataDefinitionsBundle/Resources/config/serializer/Model.Definition.yml @@ -4,7 +4,7 @@ Wvision\Bundle\DataDefinitionsBundle\Model\Definition: properties: id: expose: true - type: string + type: integer xml_attribute: true groups: [ List, Detailed ] name: diff --git a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml index e131cfec..fb48406b 100755 --- a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml +++ b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml @@ -2,10 +2,6 @@ Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinition: exclusion_policy: ALL xml_root_name: export_definition properties: - enableInheritance: - expose: true - type: boolean - groups: [Detailed] fetcher: expose: true type: string @@ -18,8 +14,3 @@ Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinition: expose: true type: boolean groups: [ Detailed ] - virtual_properties: - isWriteable: - exp: object.isWriteable() - type: boolean - serialized_name: isWriteable \ No newline at end of file diff --git a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ImportDefinition.yml b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ImportDefinition.yml index c47fa82d..1ec31c51 100755 --- a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ImportDefinition.yml +++ b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ImportDefinition.yml @@ -50,12 +50,3 @@ Wvision\Bundle\DataDefinitionsBundle\Model\ImportDefinition: expose: true type: boolean groups: [ Detailed ] - virtual_properties: - isWriteable: - exp: object.isWriteable() - type: boolean - serialized_name: isWriteable - persister: - expose: true - type: string - groups: [Detailed] \ No newline at end of file diff --git a/src/DataDefinitionsBundle/Resources/config/services.yml b/src/DataDefinitionsBundle/Resources/config/services.yml index 501efe7b..17bf7bb8 100644 --- a/src/DataDefinitionsBundle/Resources/config/services.yml +++ b/src/DataDefinitionsBundle/Resources/config/services.yml @@ -31,7 +31,6 @@ services: - '@logger' - '@pimcore.model.factory' - '@coreshop.expression_language' - - '@messenger.default_bus' - '%data_definitions.gc_cycle%' tags: - { name: monolog.logger, channel: import_definition } @@ -280,10 +279,6 @@ services: tags: - { name: data_definitions.interpreter, type: donotsetonempty, form-type: Wvision\Bundle\DataDefinitionsBundle\Form\Type\NoConfigurationType } - Wvision\Bundle\DataDefinitionsBundle\Interpreter\TypeCastingInterpreter: - tags: - - { name: data_definitions.interpreter, type: type_casting, form-type: Wvision\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\TypeCastingInterpreterType } - Wvision\Bundle\DataDefinitionsBundle\Interpreter\LinkInterpreter: tags: - { name: data_definitions.interpreter, type: link, form-type: Wvision\Bundle\DataDefinitionsBundle\Form\Type\NoConfigurationType } @@ -404,18 +399,4 @@ services: Wvision\Bundle\DataDefinitionsBundle\Service\StorageLocator: arguments: - $locator: !tagged_locator { tag: flysystem.storage } - - Wvision\Bundle\DataDefinitionsBundle\EventListener\PimcoreSettingsListener: - tags: - - { name: kernel.event_listener, event: pimcore.admin.indexAction.settings, method: indexSettings } - - Wvision\Bundle\DataDefinitionsBundle\EventListener\WriteableListener: - tags: - - { name: kernel.event_subscriber } - - Wvision\Bundle\DataDefinitionsBundle\Messenger\ImportRowMessageHandler: - arguments: - - '@Wvision\Bundle\DataDefinitionsBundle\Importer\ImporterInterface' - tags: - - { name: messenger.message_handler } + $locator: !tagged_locator { tag: flysystem.storage } \ No newline at end of file diff --git a/src/DataDefinitionsBundle/Resources/config/services/commands.yml b/src/DataDefinitionsBundle/Resources/config/services/commands.yml index ea5aa5ef..d8a32392 100644 --- a/src/DataDefinitionsBundle/Resources/config/services/commands.yml +++ b/src/DataDefinitionsBundle/Resources/config/services/commands.yml @@ -19,14 +19,6 @@ services: tags: - { name: 'console.command', command: 'data-definitions:import' } - Wvision\Bundle\DataDefinitionsBundle\Command\ImportAsyncCommand: - arguments: - - '@event_dispatcher' - - '@data_definitions.repository.import_definition' - - '@Wvision\Bundle\DataDefinitionsBundle\Importer\ImporterInterface' - tags: - - { name: 'console.command', command: 'data-definitions:async-import' } - Wvision\Bundle\DataDefinitionsBundle\Command\ExportCommand: arguments: - '@event_dispatcher' diff --git a/src/DataDefinitionsBundle/Resources/config/services/forms.yml b/src/DataDefinitionsBundle/Resources/config/services/forms.yml index dfd4632f..fb9935eb 100644 --- a/src/DataDefinitionsBundle/Resources/config/services/forms.yml +++ b/src/DataDefinitionsBundle/Resources/config/services/forms.yml @@ -5,7 +5,12 @@ parameters: data_definitions.form.type.export_mapping.validation_groups: [ data_definitions ] services: - Wvision\Bundle\DataDefinitionsBundle\Form\DataMapper\DefinitionMappingDataMapper: ~ + Wvision\Bundle\DataDefinitionsBundle\Form\DataMapper\DefinitionMappingDataMapper: + arguments: + - !service + class: Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper + arguments: + - '@property_accessor' Wvision\Bundle\DataDefinitionsBundle\Form\Type\ClassChoiceType: tags: diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/css/datadefinition.css b/src/DataDefinitionsBundle/Resources/public/pimcore/css/datadefinition.css index da4ec80e..bb84fe85 100644 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/css/datadefinition.css +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/css/datadefinition.css @@ -6,7 +6,7 @@ background: url(../img/import_definition.svg) center center no-repeat !important; } -body.pimcore_version_11 .data_definitions_nav_icon_import_definition { +body.pimcore_version_10 .data_definitions_nav_icon_import_definition { background: url(../img/import_definition_white.svg) center center no-repeat !important; } @@ -18,7 +18,7 @@ body.pimcore_version_11 .data_definitions_nav_icon_import_definition { background: url(../img/export_definition.svg) center center no-repeat !important; } -body.pimcore_version_11 .data_definitions_nav_icon_export_definition { +body.pimcore_version_10 .data_definitions_nav_icon_export_definition { background: url(../img/export_definition_white.svg) center center no-repeat !important; } diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/definition/abstractItem.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/definition/abstractItem.js index 6b64cf29..1a2fca67 100644 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/definition/abstractItem.js +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/js/definition/abstractItem.js @@ -14,10 +14,6 @@ pimcore.registerNS('pimcore.plugin.datadefinitions.definition.abstractItem'); pimcore.plugin.datadefinitions.definition.abstractItem = Class.create(coreshop.resource.item, { - saveDisabled: function() { - return false; - }, - getPanel: function () { var me = this, panel = new Ext.TabPanel({ @@ -49,8 +45,7 @@ pimcore.plugin.datadefinitions.definition.abstractItem = Class.create(coreshop.r { text: t('data_definitions_import_definition'), iconCls: 'pimcore_icon_import', - handler: this.upload.bind(this), - disabled: this.saveDisabled() + handler: this.upload.bind(this) }, { text: t('data_definitions_export_definition'), @@ -63,7 +58,6 @@ pimcore.plugin.datadefinitions.definition.abstractItem = Class.create(coreshop.r { text: t('data_definitions_duplicate_definition'), iconCls: 'pimcore_icon_copy', - disabled: this.saveDisabled(), handler: function () { var id = me.data.id; @@ -94,8 +88,7 @@ pimcore.plugin.datadefinitions.definition.abstractItem = Class.create(coreshop.r { text: t('save'), iconCls: 'pimcore_icon_apply', - handler: this.save.bind(this), - disabled: this.saveDisabled() + handler: this.save.bind(this) }], items: this.getItems() }); diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js index df699d61..cc6ecd6e 100644 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js @@ -24,10 +24,6 @@ pimcore.plugin.datadefinitions.export.item = Class.create(pimcore.plugin.datadef providers: [], - saveDisabled: function () { - return !this.data.isWriteable; - }, - getSettings: function () { var url = null; @@ -137,12 +133,6 @@ pimcore.plugin.datadefinitions.export.item = Class.create(pimcore.plugin.datadef name: 'stopOnException', checked: this.data.stopOnException }, - { - fieldLabel: t('data_definitions_enable_inheritance'), - xtype: 'checkbox', - name: 'enableInheritance', - checked: this.data.enableInheritance - }, { fieldLabel: t('data_definitions_fetcher_objects_unpublished'), xtype: 'checkbox', diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/panel.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/panel.js index d7a2c66b..0ea8a6c9 100755 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/panel.js +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/panel.js @@ -38,20 +38,6 @@ pimcore.plugin.datadefinitions.export.panel = Class.create(coreshop.resource.pan filters: [], runners: [], - - getTopBar: function () { - return [ - { - // add button - text: t('add'), - iconCls: 'pimcore_icon_add', - itemId: 'add-button', - handler: this.addItem.bind(this), - disabled: !pimcore.settings['data-definitions-import-definition-writeable'] - } - ]; - }, - getDefaultGridConfiguration: function () { return { region: 'west', diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/import/item.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/import/item.js index b10f623a..f5aad625 100644 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/import/item.js +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/js/import/item.js @@ -25,10 +25,6 @@ pimcore.plugin.datadefinitions.import.item = Class.create(pimcore.plugin.datadef providers: [], - saveDisabled: function () { - return !this.data.isWriteable; - }, - getSettings: function () { var classesStore = new Ext.data.JsonStore({ autoDestroy: true, diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/import/panel.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/import/panel.js index de5d7ff5..0943b337 100755 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/import/panel.js +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/js/import/panel.js @@ -39,19 +39,6 @@ pimcore.plugin.datadefinitions.import.panel = Class.create(coreshop.resource.pan runners: [], persisters: [], - getTopBar: function () { - return [ - { - // add button - text: t('add'), - iconCls: 'pimcore_icon_add', - itemId: 'add-button', - handler: this.addItem.bind(this), - disabled: !pimcore.settings['data-definitions-import-definition-writeable'] - } - ]; - }, - getDefaultGridConfiguration: function () { return { region: 'west', diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/interpreters/typecasting.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/interpreters/typecasting.js deleted file mode 100644 index cd846392..00000000 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/interpreters/typecasting.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Data Definitions. - * - * LICENSE - * - * This source file is subject to the GNU General Public License version 3 (GPLv3) - * For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt - * files that are distributed with this source code. - * - * @copyright Copyright (c) 2016-2019 w-vision AG (https://www.w-vision.ch) - * @license https://github.com/w-vision/DataDefinitions/blob/master/gpl-3.0.txt GNU General Public License version 3 (GPLv3) - */ - -pimcore.registerNS('pimcore.plugin.datadefinitions.interpreters.type_casting'); - -pimcore.plugin.datadefinitions.interpreters.type_casting = Class.create(pimcore.plugin.datadefinitions.interpreters.abstract, { - getLayout: function (fromColumn, toColumn, record, config) { - const typeStore = new Ext.data.ArrayStore({ - fields: ['key', 'value'], - data: [ - ['int', 'integer'], - ['float', 'float'], - ['string', 'string'], - ['boolean', 'boolean'] - ] - }); - - return [ - { - xtype: 'combo', - fieldLabel: t('type'), - name: 'toType', - displayField: 'value', - valueField: 'key', - store: typeStore, - width: 500, - value: config.Totype ? config.Totype : 'int' - }, - ]; - } -}); diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/process_manager/export_contextmenu.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/process_manager/export_contextmenu.js index cd0d4c66..3ff5b958 100644 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/process_manager/export_contextmenu.js +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/js/process_manager/export_contextmenu.js @@ -1,81 +1,95 @@ -document.addEventListener(pimcore.events.prepareObjectTreeContextMenu, function (event) { - if (!Ext.ClassManager.get('Executable')) { - Ext.define('Executable', { - extend: 'Ext.data.Model', - fields: [ - {name: 'name', type: 'string'}, - ] - }); - } +pimcore.registerNS("pimcore.plugin.datadefinitions.export.context_menu"); - const tree = event.detail.menu; - const item = event.detail.object; +pimcore.plugin.datadefinitions.export.context_menu = Class.create(pimcore.plugin.admin, { + getClassName: function () { + return "pimcore.plugin.datadefinitions.export.context_menu"; + }, - var user = pimcore.globalmanager.get('user'); - var hasExportMenu = user.isAllowed('w_vision_export_menu'); + initialize: function () { + pimcore.plugin.broker.registerPlugin(this); + }, - Ext.create('Ext.data.Store', { - model: 'Executable', - proxy: { - type: 'ajax', - url: '/admin/process_manager/executables/list-by-type', - extraParams: { - type: 'exportdefinition' - }, - reader: { - type: 'json', - rootProperty: 'data' - } - }, - sorters: [{ - property: 'name', - direction: 'ASC' - }], - sortRoot: 'data', - autoLoad: true, - listeners: { - refresh: function (store) { - var exportMenu = []; - store.each(function (executable) { - exportMenu.push({ - text: executable.get('name'), - iconCls: "pimcore_icon_object pimcore_icon_overlay_add", - handler: function () { - Ext.Ajax.request({ - url: '/admin/process_manager/executables/run', - params: { - id: executable.id, - startupConfig: Ext.encode({ - root: item.get('id'), - }), - csrfToken: pimcore.settings['csrfToken'] - }, - method: 'POST', - success: function (result) { - result = Ext.decode(result.responseText); + prepareObjectTreeContextMenu: function (tree, treeClass, menuItem) { + if (!Ext.ClassManager.get('Executable')) { + Ext.define('Executable', { + extend: 'Ext.data.Model', + fields: [ + {name: 'name', type: 'string'}, + ] + }); + } - if (result.success) { - Ext.Msg.alert(t('success'), t('processmanager_executable_started')); - } else { - Ext.Msg.alert(t('error'), result.message); - } - }.bind(this) - }); - } + var $this = this; + var _ = this, user = pimcore.globalmanager.get('user'); + var hasExportMenu = user.isAllowed('w_vision_export_menu'); + + Ext.create('Ext.data.Store', { + model: 'Executable', + proxy: { + type: 'ajax', + url: '/admin/process_manager/executables/list-by-type', + extraParams: { + type: 'exportdefinition' + }, + reader: { + type: 'json', + rootProperty: 'data' + } + }, + sorters: [{ + property: 'name', + direction: 'ASC' + }], + sortRoot: 'data', + autoLoad: true, + listeners: { + refresh: function (store) { + var exportMenu = []; + store.each(function (executable) { + exportMenu.push({ + text: executable.get('name'), + iconCls: "pimcore_icon_object pimcore_icon_overlay_add", + handler: $this.exportObjects.bind($this, executable, menuItem) + }); }); - }); - if (exportMenu && hasExportMenu) { - tree.add([ - {xtype: 'menuseparator'}, - { - text: t("data_definitions_processmanager_export_from_here"), - iconCls: "pimcore_icon_object pimcore_icon_overlay_download", - menu: exportMenu - } - ]); + if (exportMenu && hasExportMenu) { + tree.add([ + {xtype: 'menuseparator'}, + { + text: t("data_definitions_processmanager_export_from_here"), + iconCls: "pimcore_icon_object pimcore_icon_overlay_download", + menu: exportMenu + } + ]); + } } } - } - }); -}); \ No newline at end of file + }); + }, + + exportObjects: function (executable, menuItem) { + Ext.Ajax.request({ + url: '/admin/process_manager/executables/run', + params: { + id: executable.id, + startupConfig: Ext.encode({ + root: menuItem.get('id'), + }), + csrfToken: pimcore.settings['csrfToken'] + }, + method: 'POST', + success: function (result) { + result = Ext.decode(result.responseText); + + if (result.success) { + Ext.Msg.alert(t('success'), t('processmanager_executable_started')); + } else { + Ext.Msg.alert(t('error'), result.message); + } + }.bind(this) + }); + } +}); + +new pimcore.plugin.datadefinitions.export.context_menu(); diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/process_manager/export_search.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/process_manager/export_search.js index 82bb725e..235a0b4f 100644 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/process_manager/export_search.js +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/js/process_manager/export_search.js @@ -90,6 +90,7 @@ pimcore.object.search = Class.create(pimcore.object.search, { root: this.object.id, query: this.searchField.getValue(), only_direct_children: this.checkboxOnlyDirectChildren.getValue(), + condition: this.sqlEditor.getValue(), ids: ids, }), csrfToken: pimcore.settings['csrfToken'] diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/startup.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/startup.js index 9208129e..8246ce92 100755 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/startup.js +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/js/startup.js @@ -13,18 +13,16 @@ pimcore.registerNS('pimcore.plugin.data_definitions'); -pimcore.plugin.data_definitions = Class.create({ +pimcore.plugin.data_definitions = Class.create(pimcore.plugin.admin, { getClassName: function () { return 'pimcore.plugin.data_definitions'; }, initialize: function () { - document.addEventListener(pimcore.events.pimcoreReady, (e) => { - this.pimcoreReady(); - }); + pimcore.plugin.broker.registerPlugin(this); }, - pimcoreReady: function () { + pimcoreReady: function (params, broker) { var user = pimcore.globalmanager.get('user'); diff --git a/src/DataDefinitionsBundle/Resources/translations/admin.en.yml b/src/DataDefinitionsBundle/Resources/translations/admin.en.yml index 47ec156e..723f6122 100644 --- a/src/DataDefinitionsBundle/Resources/translations/admin.en.yml +++ b/src/DataDefinitionsBundle/Resources/translations/admin.en.yml @@ -44,7 +44,6 @@ data_definitions_filter: 'Filter' data_definitions_runner: 'Runner' data_definitions_create_version: 'Create new Version on every Run' data_definitions_stop_on_exception: 'Stop on Exception' -data_definitions_enable_inheritance: 'Enable Inheritance' data_definitions_installed: 'ImportDefinitions has been installed' data_definitions_uninstalled: 'ImportDefinitions has been uninstalled' data_definitions_success_document: 'Success Notification Document' diff --git a/src/DataDefinitionsBundle/Rules/Model/ImportRule.php b/src/DataDefinitionsBundle/Rules/Model/ImportRule.php index e8fa3a01..16bf733f 100644 --- a/src/DataDefinitionsBundle/Rules/Model/ImportRule.php +++ b/src/DataDefinitionsBundle/Rules/Model/ImportRule.php @@ -24,7 +24,7 @@ class ImportRule implements ImportRuleInterface protected int $id; - public function getId(): ?int + public function getId() { return $this->id; } diff --git a/src/Kernel.php b/src/Kernel.php index 4b84caec..2e2ba14d 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -17,16 +17,16 @@ class Kernel extends PimcoreKernel { - public function registerBundlesToCollection(BundleCollection $collection): void + public function registerBundlesToCollection(BundleCollection $collection) { $collection->addBundle(new \Wvision\Bundle\DataDefinitionsBundle\DataDefinitionsBundle()); $collection->addBundle(new \FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle()); } - public function boot(): void + public function boot() { - parent::boot(); - \Pimcore::setKernel($this); + + parent::boot(); } } diff --git a/tests/DataDefinitionsBundle/Behat/Context/Domain/PimcoreContext.php b/tests/DataDefinitionsBundle/Behat/Context/Domain/PimcoreContext.php index 94a74ed1..a691ed8e 100644 --- a/tests/DataDefinitionsBundle/Behat/Context/Domain/PimcoreContext.php +++ b/tests/DataDefinitionsBundle/Behat/Context/Domain/PimcoreContext.php @@ -64,7 +64,7 @@ public function thereAreUnpublishedDataObjects(int $count, ClassDefinition $defi * @var DataObject\Listing $list */ $list = $fqcn::getList(); - $list->setCondition('published=0'); + $list->setCondition('o_published=0'); Assert::eq($count, $list->getTotalCount(), sprintf( @@ -88,7 +88,7 @@ public function thereArePublishedDataObjects(int $count, ClassDefinition $defini * @var DataObject\Listing $list */ $list = $fqcn::getList(); - $list->setCondition('published=1'); + $list->setCondition('o_published=1'); Assert::eq($count, $list->getTotalCount(), sprintf( diff --git a/tests/DataDefinitionsBundle/Behat/Context/Hook/IMSetupContext.php b/tests/DataDefinitionsBundle/Behat/Context/Hook/IMSetupContext.php index 2709f863..fa471a0c 100644 --- a/tests/DataDefinitionsBundle/Behat/Context/Hook/IMSetupContext.php +++ b/tests/DataDefinitionsBundle/Behat/Context/Hook/IMSetupContext.php @@ -17,8 +17,6 @@ use Behat\Behat\Context\Context; use Wvision\Bundle\DataDefinitionsBundle\Installer; use Pimcore\Db\PhpArrayFileTable; -use Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinition; -use Wvision\Bundle\DataDefinitionsBundle\Model\ImportDefinition; final class IMSetupContext implements Context { @@ -48,30 +46,18 @@ public static function setupImportDefinitions() */ public function purgeDefinitions() { - $importDefinitions = new ImportDefinition\Listing(); - - foreach ($importDefinitions->getObjects() as $definition) { - $definition->delete(); + if (file_exists(PIMCORE_CONFIGURATION_DIRECTORY.'/importdefinitions.php')) { + unlink(PIMCORE_CONFIGURATION_DIRECTORY.'/importdefinitions.php'); } - $exportDefinitions = new ExportDefinition\Listing(); - - foreach ($exportDefinitions->getObjects() as $definition) { - $definition->delete(); + if (file_exists(PIMCORE_CONFIGURATION_DIRECTORY.'/exportdefinitions.php')) { + unlink(PIMCORE_CONFIGURATION_DIRECTORY.'/exportdefinitions.php'); } -// -// if (file_exists(PIMCORE_CONFIGURATION_DIRECTORY.'/importdefinitions.php')) { -// unlink(PIMCORE_CONFIGURATION_DIRECTORY.'/importdefinitions.php'); -// } -// -// if (file_exists(PIMCORE_CONFIGURATION_DIRECTORY.'/exportdefinitions.php')) { -// unlink(PIMCORE_CONFIGURATION_DIRECTORY.'/exportdefinitions.php'); -// } -// -// $obj = new PhpArrayFileTable(); -// $refObject = new \ReflectionObject($obj); -// $refProperty = $refObject->getProperty('tables'); -// $refProperty->setAccessible(true); -// $refProperty->setValue(null, []); + + $obj = new PhpArrayFileTable(); + $refObject = new \ReflectionObject($obj); + $refProperty = $refObject->getProperty('tables'); + $refProperty->setAccessible(true); + $refProperty->setValue(null, []); } } diff --git a/tests/DataDefinitionsBundle/Behat/Context/Hook/PimcoreDaoContext.php b/tests/DataDefinitionsBundle/Behat/Context/Hook/PimcoreDaoContext.php index 5dd74b03..b6b1c4fc 100644 --- a/tests/DataDefinitionsBundle/Behat/Context/Hook/PimcoreDaoContext.php +++ b/tests/DataDefinitionsBundle/Behat/Context/Hook/PimcoreDaoContext.php @@ -23,24 +23,14 @@ use Pimcore\Model\DataObject\Fieldcollection; use Pimcore\Model\DataObject\Listing; use Pimcore\Model\DataObject\Objectbrick; -use Symfony\Component\HttpKernel\KernelInterface; final class PimcoreDaoContext implements Context { - public function __construct( - private Connection $connection, - private KernelInterface $kernel, - ) - { - - } + private $connection; - /** - * @BeforeScenario - */ - public function setKernel(): void + public function __construct(Connection $connection) { - \Pimcore::setKernel($this->kernel); + $this->connection = $connection; } /** @@ -49,14 +39,14 @@ public function setKernel(): void public function purgeObjects() { Cache::clearAll(); - Cache\RuntimeCache::clear(); + Cache\Runtime::clear(); /** * @var Listing $list */ $list = new DataObject\Listing(); $list->setUnpublished(true); - $list->setCondition('id <> 1'); + $list->setCondition('o_id <> 1'); $list->load(); foreach ($list->getObjects() as $obj) { @@ -70,7 +60,7 @@ public function purgeObjects() public function purgeAssets() { Cache::clearAll(); - Cache\RuntimeCache::clear(); + Cache\Runtime::clear(); /** * @var Asset\Listing $list @@ -117,7 +107,7 @@ public function purgeBricks() public function clearRuntimeCacheScenario() { //Clearing it here is totally fine, since each scenario has its own separated context of objects - Cache\RuntimeCache::clear(); + \Pimcore\Cache\Runtime::clear(); } /** @@ -127,7 +117,7 @@ public function clearRuntimeCacheStep() { //We should not clear Pimcore Objects here, otherwise we lose the reference to it //and end up having the same object twice - $copy = \Pimcore\Cache\RuntimeCache::getInstance()->getArrayCopy(); + $copy = \Pimcore\Cache\Runtime::getInstance()->getArrayCopy(); $keepItems = []; foreach ($copy as $key => $value) { @@ -136,7 +126,7 @@ public function clearRuntimeCacheStep() } } - \Pimcore\Cache\RuntimeCache::clear($keepItems); + \Pimcore\Cache\Runtime::clear($keepItems); } /** diff --git a/tests/DataDefinitionsBundle/Behat/Context/Setup/PimcoreClassContext.php b/tests/DataDefinitionsBundle/Behat/Context/Setup/PimcoreClassContext.php index bd92c194..0385632a 100644 --- a/tests/DataDefinitionsBundle/Behat/Context/Setup/PimcoreClassContext.php +++ b/tests/DataDefinitionsBundle/Behat/Context/Setup/PimcoreClassContext.php @@ -79,7 +79,7 @@ public function createClassNamed($className) "bodyStyle": null, "datatype": "layout", "permissions": null, - "children": [ + "childs": [ { "fieldtype": "panel", "labelWidth": 100, @@ -95,7 +95,7 @@ public function createClassNamed($className) "bodyStyle": null, "datatype": "layout", "permissions": null, - "children": [], + "childs": [], "locked": false } ], @@ -159,7 +159,7 @@ public function createBrickNamed($brickName) "bodyStyle": null, "datatype": "layout", "permissions": null, - "children": [ + "childs": [ { "fieldtype": "panel", "labelWidth": 100, @@ -175,7 +175,7 @@ public function createBrickNamed($brickName) "bodyStyle": null, "datatype": "layout", "permissions": null, - "children": [], + "childs": [], "locked": false } ], @@ -217,7 +217,7 @@ public function createCollectionNamed($collection) "bodyStyle": null, "datatype": "layout", "permissions": null, - "children": [ + "childs": [ { "fieldtype": "panel", "labelWidth": 100, @@ -233,7 +233,7 @@ public function createCollectionNamed($collection) "bodyStyle": null, "datatype": "layout", "permissions": null, - "children": [], + "childs": [], "locked": false } ], @@ -318,9 +318,9 @@ public function definitionHasExternalImageField($definition, $name) $jsonDefinition = sprintf(' { "fieldtype": "externalImage", - "previewWidth": null, - "inputWidth": null, - "previewHeight": null, + "previewWidth": "", + "inputWidth": "", + "previewHeight": "", "name": "%s", "title": "%s", "tooltip": "", @@ -522,7 +522,7 @@ public function definitionHasLocalizedInputField($definition, $name) { "fieldtype": "localizedfields", "phpdocType": "\\Pimcore\\Model\\DataObject\\Localizedfield", - "children": [ + "childs": [ { "fieldtype": "input", "width": null, @@ -587,7 +587,7 @@ public function definitionHasLocalizedTextareaField($definition, $name) { "fieldtype": "localizedfields", "phpdocType": "\\Pimcore\\Model\\DataObject\\Localizedfield", - "children": [ + "childs": [ { "fieldtype": "textarea", "width": "", diff --git a/tests/DataDefinitionsBundle/Behat/Context/Transform/PimcoreClassContext.php b/tests/DataDefinitionsBundle/Behat/Context/Transform/PimcoreClassContext.php index dce8bc31..ce2ff728 100644 --- a/tests/DataDefinitionsBundle/Behat/Context/Transform/PimcoreClassContext.php +++ b/tests/DataDefinitionsBundle/Behat/Context/Transform/PimcoreClassContext.php @@ -17,7 +17,7 @@ use Behat\Behat\Context\Context; use Wvision\Bundle\DataDefinitionsBundle\Behat\Service\ClassStorageInterface; use Wvision\Bundle\DataDefinitionsBundle\Behat\Service\SharedStorageInterface; -use Pimcore\Cache\RuntimeCache; +use Pimcore\Cache\Runtime; use Pimcore\Model\DataObject; use Pimcore\Model\DataObject\ClassDefinition; use Pimcore\Model\DataObject\Concrete; @@ -42,7 +42,7 @@ public function __construct( */ public function class($name) { - RuntimeCache::clear(); + Runtime::clear(); $name = $this->classStorage->get($name); @@ -129,7 +129,7 @@ public function objectOfTheClass($name) */ public function definition() { - RuntimeCache::clear(); + Runtime::clear(); $name = $this->sharedStorage->get('pimcore_definition_name'); $class = $this->sharedStorage->get('pimcore_definition_class'); diff --git a/tests/DataDefinitionsBundle/Behat/Resources/config/profiles/default.yml b/tests/DataDefinitionsBundle/Behat/Resources/config/profiles/default.yml index e88d3ecd..aee25a91 100644 --- a/tests/DataDefinitionsBundle/Behat/Resources/config/profiles/default.yml +++ b/tests/DataDefinitionsBundle/Behat/Resources/config/profiles/default.yml @@ -9,6 +9,6 @@ default: FriendsOfBehat\SymfonyExtension: bootstrap: behat-bootstrap.php kernel: - path: src/BehatKernel.php - class: BehatKernel + path: src/Kernel.php + class: Kernel environment: test diff --git a/tests/DataDefinitionsBundle/Behat/Resources/config/services/contexts/hook.yml b/tests/DataDefinitionsBundle/Behat/Resources/config/services/contexts/hook.yml index d11a7946..8b689ee8 100644 --- a/tests/DataDefinitionsBundle/Behat/Resources/config/services/contexts/hook.yml +++ b/tests/DataDefinitionsBundle/Behat/Resources/config/services/contexts/hook.yml @@ -6,7 +6,6 @@ services: class: Wvision\Bundle\DataDefinitionsBundle\Behat\Context\Hook\PimcoreDaoContext arguments: - '@doctrine.dbal.default_connection' - - '@kernel' tags: - { name: fob.context_service }