From d646f098b29b04f4705e425cd38bfead70c089d0 Mon Sep 17 00:00:00 2001 From: Robin Delattre Date: Thu, 18 Apr 2024 21:38:40 +0200 Subject: [PATCH 1/2] Compatibility with doctrine dbal 4 (#1677) --- composer.json | 2 +- docs/reference/installation.rst | 1 + src/Entity/BaseUser3.php | 30 +++++++++++++++++++ .../config/doctrine/BaseUser3.orm.xml | 22 ++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/Entity/BaseUser3.php create mode 100644 src/Resources/config/doctrine/BaseUser3.orm.xml diff --git a/composer.json b/composer.json index 3e12b72fa..b6b5ea66c 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "dama/doctrine-test-bundle": "^7.0", "doctrine/doctrine-bundle": "^2.7", "doctrine/mongodb-odm": "^2.3", - "doctrine/orm": "^2.14", + "doctrine/orm": "^2.14 || ^3.0", "egulias/email-validator": "^3.1 || ^4.0", "friendsofphp/php-cs-fixer": "^3.4", "matthiasnoback/symfony-config-test": "^4.2", diff --git a/docs/reference/installation.rst b/docs/reference/installation.rst index f43353c4c..f318a65a8 100644 --- a/docs/reference/installation.rst +++ b/docs/reference/installation.rst @@ -82,6 +82,7 @@ And then create the corresponding entity, ``src/Entity/SonataUserUser``:: use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Sonata\UserBundle\Entity\BaseUser; + // or `Sonata\UserBundle\Entity\BaseUser3` as BaseUser if you upgrade to doctrine/orm ^3 #[ORM\Entity] #[ORM\Table(name: 'user__user')] diff --git a/src/Entity/BaseUser3.php b/src/Entity/BaseUser3.php new file mode 100644 index 000000000..1969326b4 --- /dev/null +++ b/src/Entity/BaseUser3.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Sonata\UserBundle\Entity; + +use Sonata\UserBundle\Model\User as AbstractedUser; + +class BaseUser3 extends AbstractedUser +{ + public function prePersist(): void + { + $this->createdAt = new \DateTime(); + $this->updatedAt = new \DateTime(); + } + + public function preUpdate(): void + { + $this->updatedAt = new \DateTime(); + } +} diff --git a/src/Resources/config/doctrine/BaseUser3.orm.xml b/src/Resources/config/doctrine/BaseUser3.orm.xml new file mode 100644 index 000000000..6ebf323c6 --- /dev/null +++ b/src/Resources/config/doctrine/BaseUser3.orm.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + From 14bde91fef2b47b4679d8ca7fc3e8a9b0f2105fb Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 18 Apr 2024 21:43:56 +0200 Subject: [PATCH 2/2] 5.12.0 (#1684) --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af9bf03f1..d702b701f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [5.12.0](https://github.com/sonata-project/SonataUserBundle/compare/5.11.0...5.12.0) - 2024-04-18 +### Added +- [[#1677](https://github.com/sonata-project/SonataUserBundle/pull/1677)] BaseUser3 with roles mapped type as `json` to be compatible with ORM 3 ([@RobinDev](https://github.com/RobinDev)) + ## [5.11.0](https://github.com/sonata-project/SonataUserBundle/compare/5.10.0...5.11.0) - 2024-03-08 ### Added - [[#1661](https://github.com/sonata-project/SonataUserBundle/pull/1661)] Default value `true` for the "multiple" option at `RolesMatrixType` form type ([@phansys](https://github.com/phansys))