Skip to content

Commit

Permalink
Merge 5.x into 6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed Apr 19, 2024
2 parents 5dd2429 + 14bde91 commit 3830e68
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions docs/reference/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand Down
30 changes: 30 additions & 0 deletions src/Entity/BaseUser3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* 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();
}
}
22 changes: 22 additions & 0 deletions src/Resources/config/doctrine/BaseUser3.orm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Sonata\UserBundle\Entity\BaseUser3">
<field name="username" column="username" type="string" length="180"/>
<field name="usernameCanonical" column="username_canonical" type="string" length="180" unique="true"/>
<field name="email" column="email" type="string" length="180"/>
<field name="emailCanonical" column="email_canonical" type="string" length="180" unique="true"/>
<field name="enabled" column="enabled" type="boolean"/>
<field name="salt" column="salt" type="string" nullable="true"/>
<field name="password" column="password" type="string"/>
<field name="lastLogin" column="last_login" type="datetime" nullable="true"/>
<field name="confirmationToken" column="confirmation_token" type="string" length="180" unique="true" nullable="true"/>
<field name="passwordRequestedAt" column="password_requested_at" type="datetime" nullable="true"/>
<field name="roles" column="roles" type="json"/>
<field name="createdAt" type="datetime" column="created_at"/>
<field name="updatedAt" type="datetime" column="updated_at"/>
<lifecycle-callbacks>
<lifecycle-callback type="prePersist" method="prePersist"/>
<lifecycle-callback type="preUpdate" method="preUpdate"/>
</lifecycle-callbacks>
</mapped-superclass>
</doctrine-mapping>

0 comments on commit 3830e68

Please sign in to comment.