Migrate to JMS attributes

This commit is contained in:
Yassine Guedidi
2025-04-05 15:12:30 +02:00
parent a1440dffda
commit a766826a69
8 changed files with 96 additions and 183 deletions

View File

@ -20,14 +20,13 @@ use Wallabag\Repository\UserRepository;
/**
* User.
*
* @XmlRoot("user")
*/
#[ORM\Table(name: '`user`')]
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[UniqueEntity('email')]
#[UniqueEntity('username')]
#[XmlRoot('user')]
class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorInterface, BackupCodeInterface
{
use EntityTimestampsTrait;
@ -41,12 +40,11 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* type="int",
* example=12,
* )
*
* @Groups({"user_api", "user_api_with_client"})
*/
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
#[Groups(['user_api', 'user_api_with_client'])]
protected $id;
/**
@ -57,9 +55,9 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* type="string",
* example="Walla Baggger",
* )
* @Groups({"user_api", "user_api_with_client"})
*/
#[ORM\Column(name: 'name', type: 'text', nullable: true)]
#[Groups(['user_api', 'user_api_with_client'])]
protected $name;
/**
@ -70,9 +68,8 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* type="string",
* example="wallabag",
* )
*
* @Groups({"user_api", "user_api_with_client"})
*/
#[Groups(['user_api', 'user_api_with_client'])]
protected $username;
/**
@ -83,9 +80,8 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* type="string",
* example="wallabag@wallabag.io",
* )
*
* @Groups({"user_api", "user_api_with_client"})
*/
#[Groups(['user_api', 'user_api_with_client'])]
protected $email;
/**
@ -96,9 +92,9 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* type="string",
* example="2023-06-27T19:25:44+0000",
* )
* @Groups({"user_api", "user_api_with_client"})
*/
#[ORM\Column(name: 'created_at', type: 'datetime')]
#[Groups(['user_api', 'user_api_with_client'])]
protected $createdAt;
/**
@ -109,9 +105,9 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* type="string",
* example="2023-06-27T19:37:30+0000",
* )
* @Groups({"user_api", "user_api_with_client"})
*/
#[ORM\Column(name: 'updated_at', type: 'datetime')]
#[Groups(['user_api', 'user_api_with_client'])]
protected $updatedAt;
#[ORM\OneToMany(targetEntity: Entry::class, mappedBy: 'user', cascade: ['remove'])]
@ -139,10 +135,9 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* description="Default client created during user registration. Used for further authorization",
* ref=@Model(type=Client::class, groups={"user_api_with_client"})
* )
*
* @Groups({"user_api_with_client"})
* @Accessor(getter="getFirstClient")
*/
#[Groups(['user_api_with_client'])]
#[Accessor(getter: 'getFirstClient')]
protected $default_client;
#[ORM\Column(type: 'integer', nullable: true)]