From a1dd9d65d23cebdfcabebb5af4d3a84438e6a378 Mon Sep 17 00:00:00 2001 From: Linus Metzler Date: Thu, 5 Oct 2023 16:58:08 +0200 Subject: [PATCH] Pimcore 11 --- .github/workflows/php.yml | 10 ++++----- composer.json | 14 ++++--------- phpstan-baseline.neon | 18 ---------------- rector.php | 24 ++++++++++++++++++++++ src/Controller/FormController.php | 2 +- src/Form/Output/EmailOutput.php | 2 +- src/Form/Transformer/ButtonTransformer.php | 2 +- src/Form/Transformer/ChoiceTransformer.php | 12 ++++++++--- src/Form/Transformer/FileTransformer.php | 2 +- src/Resources/public/js/pimcore/startup.js | 17 --------------- src/ValanticPimcoreFormsBundle.php | 7 ------- vendor-bin/phpcs/composer.json | 2 +- vendor-bin/phpcs/composer.lock | 17 +++++++-------- 13 files changed, 53 insertions(+), 76 deletions(-) create mode 100644 rector.php delete mode 100644 src/Resources/public/js/pimcore/startup.js diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index a393eed..ac9cb43 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -12,16 +12,14 @@ jobs: fail-fast: false matrix: operating-system: [ ubuntu-latest ] - php: [ "8.0", "8.1" ] - pimcore: [ '^10.0' ] + php: [ "8.1", "8.2" ] + pimcore: [ '^11.0' ] stability: [ prefer-lowest, prefer-stable ] - exclude: - - stability: prefer-lowest # TODO: remove ASAP steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} @@ -54,7 +52,7 @@ jobs: operating-system: [ ubuntu-latest ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/composer.json b/composer.json index 99d8553..460d5dd 100644 --- a/composer.json +++ b/composer.json @@ -4,12 +4,12 @@ "description": "Forms for Pimcore", "type": "pimcore-bundle", "require": { - "php": "^8.0", + "php": "^8.1", "ext-json": "*", - "limenius/liform": "dev-master#28828461425acfb9d30ae02f554055be17ca5530", - "pimcore/pimcore": "^10.0", + "limenius/liform": "^0.19", + "pimcore/pimcore": "^11.0", "ramsey/uuid": "^4.0", - "symfony/form": "^5.0", + "symfony/form": "^6.0", "voku/portable-ascii": "^1.5 || ^2.0" }, "require-dev": { @@ -18,12 +18,6 @@ "phpstan/phpstan-deprecation-rules": "^1.1.4", "phpstan/extension-installer": "^1.3.1" }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/phpwutz/Liform" - } - ], "autoload": { "psr-4": { "Valantic\\PimcoreFormsBundle\\": "src/" diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6ef4e6c..516f45f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -55,14 +55,6 @@ parameters: count: 1 path: src/Form/FormErrorNormalizer.php - - - message: """ - #^Call to deprecated method setSubject\\(\\) of class Pimcore\\\\Mail\\: - use subject\\(\\) instead\\. Will be removed in Pimcore 11$# - """ - count: 1 - path: src/Form/Output/EmailOutput.php - - message: "#^Method Valantic\\\\PimcoreFormsBundle\\\\Form\\\\Transformer\\\\ButtonTransformer\\:\\:transform\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -73,11 +65,6 @@ parameters: count: 1 path: src/Form/Transformer/ChoiceTransformer.php - - - message: "#^Method Valantic\\\\PimcoreFormsBundle\\\\Form\\\\Transformer\\\\ChoiceTransformer\\:\\:transformMultiple\\(\\) has no return type specified\\.$#" - count: 1 - path: src/Form/Transformer/ChoiceTransformer.php - - message: "#^Method Valantic\\\\PimcoreFormsBundle\\\\Form\\\\Transformer\\\\ChoiceTransformer\\:\\:transformMultiple\\(\\) has parameter \\$choices with no type specified\\.$#" count: 1 @@ -88,11 +75,6 @@ parameters: count: 1 path: src/Form/Transformer/ChoiceTransformer.php - - - message: "#^Method Valantic\\\\PimcoreFormsBundle\\\\Form\\\\Transformer\\\\ChoiceTransformer\\:\\:transformSingle\\(\\) has no return type specified\\.$#" - count: 1 - path: src/Form/Transformer/ChoiceTransformer.php - - message: "#^Method Valantic\\\\PimcoreFormsBundle\\\\Form\\\\Transformer\\\\ChoiceTransformer\\:\\:transformSingle\\(\\) has parameter \\$choices with no type specified\\.$#" count: 1 diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..5b5ac1d --- /dev/null +++ b/rector.php @@ -0,0 +1,24 @@ +paths([ + __DIR__ . '/src', + ]); + + $rectorConfig->skip([ + ]); + + $rectorConfig->sets([ + LevelSetList::UP_TO_PHP_81, + SetList::CODE_QUALITY, + ]); +}; diff --git a/src/Controller/FormController.php b/src/Controller/FormController.php index 87ef121..4d236c9 100644 --- a/src/Controller/FormController.php +++ b/src/Controller/FormController.php @@ -65,7 +65,7 @@ public function apiAction(string $name, FormService $formService, Request $reque $form = $formService->buildForm($name); $form->handleRequest($request); - if (!$form->isSubmitted() && $request->getContentType() === 'json') { + if (!$form->isSubmitted() && $request->getContentTypeFormat() === 'json') { $content = (string) $request->getContent(); $data = json_decode($content, true, flags: \JSON_THROW_ON_ERROR); diff --git a/src/Form/Output/EmailOutput.php b/src/Form/Output/EmailOutput.php index a6ce06f..9204953 100644 --- a/src/Form/Output/EmailOutput.php +++ b/src/Form/Output/EmailOutput.php @@ -25,7 +25,7 @@ public function handle(OutputResponse $outputResponse): OutputResponse $subject = $this->getSubject(); if ($subject !== null) { - $mail->setSubject($subject); + $mail->subject($subject); } $from = $this->getFrom(); diff --git a/src/Form/Transformer/ButtonTransformer.php b/src/Form/Transformer/ButtonTransformer.php index 0a3b546..571eb53 100644 --- a/src/Form/Transformer/ButtonTransformer.php +++ b/src/Form/Transformer/ButtonTransformer.php @@ -11,7 +11,7 @@ class ButtonTransformer extends AbstractTransformer { use OverwriteAbstractTransformerTrait; - public function transform(FormInterface $form, array $extensions = [], $widget = null) + public function transform(FormInterface $form, array $extensions = [], $widget = null): array { $schema = ['type' => 'string']; diff --git a/src/Form/Transformer/ChoiceTransformer.php b/src/Form/Transformer/ChoiceTransformer.php index 0f834e4..5db0e4a 100644 --- a/src/Form/Transformer/ChoiceTransformer.php +++ b/src/Form/Transformer/ChoiceTransformer.php @@ -20,7 +20,7 @@ class ChoiceTransformer extends \Limenius\Liform\Transformer\ChoiceTransformer /** * {@inheritDoc} */ - public function transform(FormInterface $form, array $extensions = [], $widget = null) + public function transform(FormInterface $form, array $extensions = [], $widget = null): array { $formView = $form->createView(); @@ -47,7 +47,10 @@ public function transform(FormInterface $form, array $extensions = [], $widget = return $this->addCommonSpecs($form, $schema, $extensions, $widget); } - private function transformSingle(FormInterface $form, $choices, $titles) + /** + * @return array + */ + private function transformSingle(FormInterface $form, $choices, $titles): array { $formView = $form->createView(); @@ -67,7 +70,10 @@ private function transformSingle(FormInterface $form, $choices, $titles) return $schema; } - private function transformMultiple(FormInterface $form, $choices, $titles) + /** + * @return array + */ + private function transformMultiple(FormInterface $form, $choices, $titles): array { $formView = $form->createView(); diff --git a/src/Form/Transformer/FileTransformer.php b/src/Form/Transformer/FileTransformer.php index 11cb35a..003245e 100644 --- a/src/Form/Transformer/FileTransformer.php +++ b/src/Form/Transformer/FileTransformer.php @@ -11,7 +11,7 @@ class FileTransformer extends StringTransformer /** * {@inheritDoc} */ - public function transform(FormInterface $form, array $extensions = [], $widget = null) + public function transform(FormInterface $form, array $extensions = [], $widget = null): array { $schema = ['type' => 'file']; diff --git a/src/Resources/public/js/pimcore/startup.js b/src/Resources/public/js/pimcore/startup.js deleted file mode 100644 index 7536266..0000000 --- a/src/Resources/public/js/pimcore/startup.js +++ /dev/null @@ -1,17 +0,0 @@ -pimcore.registerNS("pimcore.plugin.ValanticPimcoreFormsBundle"); - -pimcore.plugin.ValanticPimcoreFormsBundle = Class.create(pimcore.plugin.admin, { - getClassName: function () { - return "pimcore.plugin.ValanticPimcoreFormsBundle"; - }, - - initialize: function () { - pimcore.plugin.broker.registerPlugin(this); - }, - - pimcoreReady: function (params, broker) { - // alert("ValanticPimcoreFormsBundle ready!"); - } -}); - -var ValanticPimcoreFormsBundlePlugin = new pimcore.plugin.ValanticPimcoreFormsBundle(); diff --git a/src/ValanticPimcoreFormsBundle.php b/src/ValanticPimcoreFormsBundle.php index 96052ee..032ed19 100644 --- a/src/ValanticPimcoreFormsBundle.php +++ b/src/ValanticPimcoreFormsBundle.php @@ -22,13 +22,6 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new ExtensionCompilerPass()); } - public function getJsPaths(): array - { - return [ - '/bundles/valanticpimcoreforms/js/pimcore/startup.js', - ]; - } - protected function getComposerPackageName(): string { $composer = file_get_contents(__DIR__ . '/../composer.json'); diff --git a/vendor-bin/phpcs/composer.json b/vendor-bin/phpcs/composer.json index dc7c097..9a3bc90 100644 --- a/vendor-bin/phpcs/composer.json +++ b/vendor-bin/phpcs/composer.json @@ -1,5 +1,5 @@ { "require-dev": { - "friendsofphp/php-cs-fixer": "^3.34.0" + "friendsofphp/php-cs-fixer": "^3.34.1" } } diff --git a/vendor-bin/phpcs/composer.lock b/vendor-bin/phpcs/composer.lock index 0380784..fc91d41 100644 --- a/vendor-bin/phpcs/composer.lock +++ b/vendor-bin/phpcs/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a21e01af9414c7adb73c7cbcc3b1c446", + "content-hash": "caec17ed17fd032812f9542df7b5294e", "packages": [], "packages-dev": [ { @@ -227,16 +227,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.34.0", + "version": "v3.34.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "7c7a4ad2ed8fe50df3e25528218b13d383608f23" + "reference": "98bf1b1068b4ceddbbc2a2b70b67a5e380add9e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/7c7a4ad2ed8fe50df3e25528218b13d383608f23", - "reference": "7c7a4ad2ed8fe50df3e25528218b13d383608f23", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/98bf1b1068b4ceddbbc2a2b70b67a5e380add9e3", + "reference": "98bf1b1068b4ceddbbc2a2b70b67a5e380add9e3", "shasum": "" }, "require": { @@ -257,9 +257,6 @@ "symfony/process": "^5.4 || ^6.0", "symfony/stopwatch": "^5.4 || ^6.0" }, - "conflict": { - "stevebauman/unfinalize": "*" - }, "require-dev": { "facile-it/paraunit": "^1.3 || ^2.0", "justinrainbow/json-schema": "^5.2", @@ -313,7 +310,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.34.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.34.1" }, "funding": [ { @@ -321,7 +318,7 @@ "type": "github" } ], - "time": "2023-09-29T15:34:26+00:00" + "time": "2023-10-03T23:51:05+00:00" }, { "name": "psr/container",