From 475250ca158b7acba3d2919d6ed8935c8f4a3b34 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Thu, 22 Feb 2024 18:28:31 +0100 Subject: [PATCH] Switch to Symfony uid --- composer.json | 3 +-- config/packages/uid.yaml | 4 ++++ .../Migrations/Version20231106190918.php | 2 +- .../Resources/config/app/config.yml | 8 ------- .../doctrine/model/PaymentRequest.orm.xml | 2 +- src/Sylius/Bundle/PaymentBundle/composer.json | 4 +--- .../Payment/Model/PaymentRequest.php | 7 +++--- .../Payment/Model/PaymentRequestInterface.php | 3 ++- src/Sylius/Component/Payment/composer.json | 3 ++- symfony.lock | 24 +++++++++---------- 10 files changed, 28 insertions(+), 32 deletions(-) create mode 100644 config/packages/uid.yaml diff --git a/composer.json b/composer.json index 473e9dff0c..bb1e4bdd96 100644 --- a/composer.json +++ b/composer.json @@ -70,8 +70,6 @@ "psr/http-client": "^1.0", "psr/http-message": "^1.0", "psr/log": "^2.0", - "ramsey/uuid": "^4.0", - "ramsey/uuid-doctrine": "^2.0", "sonata-project/block-bundle": "^4.2 || ^5.0", "stof/doctrine-extensions-bundle": "^1.4", "sylius-labs/association-hydrator": "^1.1 || ^1.2", @@ -133,6 +131,7 @@ "symfony/translation": "^6.4.0", "symfony/translation-contracts": "^2.5.2", "symfony/twig-bundle": "^6.4.0", + "symfony/uid": "^6.4.0", "symfony/ux-autocomplete": "^2.17", "symfony/ux-live-component": "^2.17", "symfony/ux-twig-component": "^2.17", diff --git a/config/packages/uid.yaml b/config/packages/uid.yaml new file mode 100644 index 0000000000..01520944f5 --- /dev/null +++ b/config/packages/uid.yaml @@ -0,0 +1,4 @@ +framework: + uid: + default_uuid_version: 7 + time_based_uuid_version: 7 diff --git a/src/Sylius/Bundle/CoreBundle/Migrations/Version20231106190918.php b/src/Sylius/Bundle/CoreBundle/Migrations/Version20231106190918.php index ee601d69b5..2a5e1ae996 100644 --- a/src/Sylius/Bundle/CoreBundle/Migrations/Version20231106190918.php +++ b/src/Sylius/Bundle/CoreBundle/Migrations/Version20231106190918.php @@ -25,7 +25,7 @@ final class Version20231106190918 extends AbstractMigration public function up(Schema $schema): void { - $this->addSql('CREATE TABLE sylius_payment_request (hash CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', method_id INT DEFAULT NULL, payment_id INT DEFAULT NULL, state VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, request_payload LONGTEXT NOT NULL COMMENT \'(DC2Type:object)\', response_data JSON NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_86D904B19883967 (method_id), INDEX IDX_86D904B4C3A3BB (payment_id), PRIMARY KEY(hash)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE sylius_payment_request (hash BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', method_id INT DEFAULT NULL, payment_id INT DEFAULT NULL, state VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, request_payload LONGTEXT NOT NULL COMMENT \'(DC2Type:object)\', response_data JSON NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_86D904B19883967 (method_id), INDEX IDX_86D904B4C3A3BB (payment_id), PRIMARY KEY(hash)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('ALTER TABLE sylius_payment_request ADD CONSTRAINT FK_86D904B19883967 FOREIGN KEY (method_id) REFERENCES sylius_payment_method (id)'); $this->addSql('ALTER TABLE sylius_payment_request ADD CONSTRAINT FK_86D904B4C3A3BB FOREIGN KEY (payment_id) REFERENCES sylius_payment (id)'); } diff --git a/src/Sylius/Bundle/PaymentBundle/Resources/config/app/config.yml b/src/Sylius/Bundle/PaymentBundle/Resources/config/app/config.yml index dfc0ec5120..3615048869 100644 --- a/src/Sylius/Bundle/PaymentBundle/Resources/config/app/config.yml +++ b/src/Sylius/Bundle/PaymentBundle/Resources/config/app/config.yml @@ -1,14 +1,6 @@ # This file is part of the Sylius package. # (c) Sylius Sp. z o.o. -parameters: - sylius.uuid_type: Ramsey\Uuid\Doctrine\UuidType - -doctrine: - dbal: - types: - uuid: "%sylius.uuid_type%" - jms_serializer: metadata: directories: diff --git a/src/Sylius/Bundle/PaymentBundle/Resources/config/doctrine/model/PaymentRequest.orm.xml b/src/Sylius/Bundle/PaymentBundle/Resources/config/doctrine/model/PaymentRequest.orm.xml index 7617b94729..7fbb85b2c4 100644 --- a/src/Sylius/Bundle/PaymentBundle/Resources/config/doctrine/model/PaymentRequest.orm.xml +++ b/src/Sylius/Bundle/PaymentBundle/Resources/config/doctrine/model/PaymentRequest.orm.xml @@ -17,7 +17,7 @@ - + diff --git a/src/Sylius/Bundle/PaymentBundle/composer.json b/src/Sylius/Bundle/PaymentBundle/composer.json index c2a03d9159..dce6337dad 100644 --- a/src/Sylius/Bundle/PaymentBundle/composer.json +++ b/src/Sylius/Bundle/PaymentBundle/composer.json @@ -29,9 +29,7 @@ "php": "^8.2", "sylius/payment": "^2.0", "sylius/resource-bundle": "^1.10", - "symfony/framework-bundle": "^6.4.1", - "symfony/messenger": "^6.4.0", - "ramsey/uuid-doctrine": "^2.0" + "symfony/framework-bundle": "^6.4.1" }, "conflict": { "doctrine/orm": "2.15.2" diff --git a/src/Sylius/Component/Payment/Model/PaymentRequest.php b/src/Sylius/Component/Payment/Model/PaymentRequest.php index 2880153b3f..b0da94ce9e 100644 --- a/src/Sylius/Component/Payment/Model/PaymentRequest.php +++ b/src/Sylius/Component/Payment/Model/PaymentRequest.php @@ -14,12 +14,13 @@ declare(strict_types=1); namespace Sylius\Component\Payment\Model; use Sylius\Component\Resource\Model\TimestampableTrait; +use Symfony\Component\Uid\Uuid; class PaymentRequest implements PaymentRequestInterface { use TimestampableTrait; - protected ?string $hash = null; + protected ?Uuid $hash = null; protected ?PaymentMethodInterface $method = null; @@ -40,10 +41,10 @@ class PaymentRequest implements PaymentRequestInterface public function getId(): ?string { - return $this->getHash(); + return $this->getHash()?->toBinary(); } - public function getHash(): ?string + public function getHash(): ?Uuid { return $this->hash; } diff --git a/src/Sylius/Component/Payment/Model/PaymentRequestInterface.php b/src/Sylius/Component/Payment/Model/PaymentRequestInterface.php index 554d488f94..d9e35cb3f9 100644 --- a/src/Sylius/Component/Payment/Model/PaymentRequestInterface.php +++ b/src/Sylius/Component/Payment/Model/PaymentRequestInterface.php @@ -15,6 +15,7 @@ namespace Sylius\Component\Payment\Model; use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Model\TimestampableInterface; +use Symfony\Component\Uid\Uuid; interface PaymentRequestInterface extends TimestampableInterface, ResourceInterface { @@ -40,7 +41,7 @@ interface PaymentRequestInterface extends TimestampableInterface, ResourceInterf public const DATA_TYPE_PAYOUT = 'payout'; - public function getHash(): ?string; + public function getHash(): ?Uuid; public function getMethod(): ?PaymentMethodInterface; diff --git a/src/Sylius/Component/Payment/composer.json b/src/Sylius/Component/Payment/composer.json index 2c6b5fae15..0ee205ff8e 100644 --- a/src/Sylius/Component/Payment/composer.json +++ b/src/Sylius/Component/Payment/composer.json @@ -28,7 +28,8 @@ "require": { "php": "^8.2", "sylius/registry": "^1.6", - "sylius/resource": "^1.10" + "sylius/resource": "^1.10", + "symfony/uid": "^5.4.21 || ^6.4" }, "require-dev": { "phpspec/phpspec": "^7.2" diff --git a/symfony.lock b/symfony.lock index 2755d00962..a9dc54b277 100644 --- a/symfony.lock +++ b/symfony.lock @@ -466,18 +466,6 @@ "ralouphie/getallheaders": { "version": "3.0.3" }, - "ramsey/uuid": { - "version": "3.8.0" - }, - "ramsey/uuid-doctrine": { - "version": "2.0", - "recipe": { - "repo": "github.com/symfony/recipes-contrib", - "branch": "main", - "version": "1.3", - "ref": "471aed0fbf5620b8d7f92b7a5ebbbf6c0945c27a" - } - }, "rector/rector": { "version": "0.11.52" }, @@ -879,6 +867,18 @@ "templates/base.html.twig" ] }, + "symfony/uid": { + "version": "6.4", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "6.2", + "ref": "d294ad4add3e15d7eb1bae0221588ca89b38e558" + }, + "files": [ + "config/packages/uid.yaml" + ] + }, "symfony/ux-autocomplete": { "version": "2.9999999", "recipe": {