From 41e245fda43a87c19e8d75b34577e698dee704c8 Mon Sep 17 00:00:00 2001 From: claudiu Date: Tue, 31 Oct 2023 17:20:07 +0200 Subject: [PATCH 1/2] changed all entities that uses doctrine annotation mappings with doctrin attribute mappings --- config/autoload/doctrine.global.php | 8 ++-- src/Admin/src/Entity/Admin.php | 31 ++++++-------- src/Admin/src/Entity/AdminRole.php | 11 +++-- src/App/src/Entity/OAuthAccessToken.php | 40 ++++++++----------- src/App/src/Entity/OAuthAuthCode.php | 36 +++++++---------- src/App/src/Entity/OAuthClient.php | 31 ++++++-------- src/App/src/Entity/OAuthRefreshToken.php | 25 +++++------- src/App/src/Entity/OAuthScope.php | 21 +++++----- src/App/src/Entity/TimestampAwareTrait.php | 10 ++--- src/App/src/Entity/UuidAwareTrait.php | 10 ++--- src/User/src/Entity/User.php | 37 ++++++++--------- src/User/src/Entity/UserAvatar.php | 19 ++++----- src/User/src/Entity/UserDetail.php | 21 +++++----- .../src/Entity/UserResetPasswordEntity.php | 18 +++------ src/User/src/Entity/UserRole.php | 19 ++++----- 15 files changed, 141 insertions(+), 196 deletions(-) diff --git a/config/autoload/doctrine.global.php b/config/autoload/doctrine.global.php index 36a7298..790b1c8 100644 --- a/config/autoload/doctrine.global.php +++ b/config/autoload/doctrine.global.php @@ -3,7 +3,7 @@ declare(strict_types=1); use Doctrine\Common\Cache\PhpFileCache; -use Doctrine\ORM\Mapping\Driver\AnnotationDriver; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; use Ramsey\Uuid\Doctrine\UuidBinaryOrderedTimeType; use Ramsey\Uuid\Doctrine\UuidBinaryType; @@ -29,17 +29,17 @@ ], ], 'AdminEntities' => [ - 'class' => AnnotationDriver::class, + 'class' => AttributeDriver::class, 'cache' => 'array', 'paths' => __DIR__ . '/../../src/Admin/src/Entity', ], 'UserEntities' => [ - 'class' => AnnotationDriver::class, + 'class' => AttributeDriver::class, 'cache' => 'array', 'paths' => __DIR__ . '/../../src/User/src/Entity', ], 'AppEntities' => [ - 'class' => AnnotationDriver::class, + 'class' => AttributeDriver::class, 'cache' => 'array', 'paths' => __DIR__ . '/../../src/App/src/Entity', ], diff --git a/src/Admin/src/Entity/Admin.php b/src/Admin/src/Entity/Admin.php index 52499f1..400dcd3 100644 --- a/src/Admin/src/Entity/Admin.php +++ b/src/Admin/src/Entity/Admin.php @@ -4,6 +4,7 @@ namespace Api\Admin\Entity; +use Api\Admin\Repository\AdminRepository; use Api\App\Entity\AbstractEntity; use Api\App\Entity\PasswordTrait; use Api\App\Entity\RoleInterface; @@ -13,11 +14,9 @@ use Exception; use League\OAuth2\Server\Entities\UserEntityInterface; -/** - * @ORM\Entity(repositoryClass="Api\Admin\Repository\AdminRepository") - * @ORM\Table(name="admin") - * @ORM\HasLifecycleCallbacks() - */ +#[ORM\Entity(repositoryClass: AdminRepository::class)] +#[ORM\Table("admin")] +#[ORM\HasLifecycleCallbacks] class Admin extends AbstractEntity implements UserEntityInterface { use PasswordTrait; @@ -29,29 +28,25 @@ class Admin extends AbstractEntity implements UserEntityInterface self::STATUS_INACTIVE, ]; - /** @ORM\Column(name="identity", type="string", length=100, unique=true) */ + #[ORM\Column(name: "identity", type: "string", length: 100, unique: true)] protected string $identity; - /** @ORM\Column(name="firstName", type="string", length=255) */ + #[ORM\Column(name: "firstName", type: "string", length: 255)] protected string $firstName; - /** @ORM\Column(name="lastName", type="string", length=255) */ + #[ORM\Column(name: "lastName", type: "string", length: 255)] protected string $lastName; - /** @ORM\Column(name="password", type="string", length=100) */ + #[ORM\Column(name: "password", type: "string", length: 100)] protected string $password; - /** @ORM\Column(name="status", type="string", length=20) */ + #[ORM\Column(name: "status", type: "string", length: 20)] protected string $status = self::STATUS_ACTIVE; - /** - * @ORM\ManyToMany(targetEntity="Api\Admin\Entity\AdminRole") - * @ORM\JoinTable( - * name="admin_roles", - * joinColumns={@ORM\JoinColumn(name="userUuid", referencedColumnName="uuid")}, - * inverseJoinColumns={@ORM\JoinColumn(name="roleUuid", referencedColumnName="uuid")} - * ) - */ + #[ORM\ManyToMany(targetEntity: AdminRole::class)] + #[ORM\JoinTable(name: "admin_roles")] + #[ORM\JoinColumn(name: "userUuid", referencedColumnName: "uuid")] + #[ORM\InverseJoinColumn(name: "roleUuid", referencedColumnName: "uuid")] protected Collection $roles; public function __construct() diff --git a/src/Admin/src/Entity/AdminRole.php b/src/Admin/src/Entity/AdminRole.php index 52a2965..0cc4914 100644 --- a/src/Admin/src/Entity/AdminRole.php +++ b/src/Admin/src/Entity/AdminRole.php @@ -4,15 +4,14 @@ namespace Api\Admin\Entity; +use Api\Admin\Repository\AdminRoleRepository; use Api\App\Entity\AbstractEntity; use Api\App\Entity\RoleInterface; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity(repositoryClass="Api\Admin\Repository\AdminRoleRepository") - * @ORM\Table(name="admin_role") - * @ORM\HasLifecycleCallbacks() - */ +#[ORM\Entity(repositoryClass: AdminRoleRepository::class)] +#[ORM\Table("admin_role")] +#[ORM\HasLifecycleCallbacks] class AdminRole extends AbstractEntity implements RoleInterface { public const ROLE_ADMIN = 'admin'; @@ -22,7 +21,7 @@ class AdminRole extends AbstractEntity implements RoleInterface self::ROLE_SUPERUSER, ]; - /** @ORM\Column(name="name", type="string", length=30, unique=true) */ + #[ORM\Column(name: "name", type: "string", length: 30, unique: true)] protected string $name; public function getName(): string diff --git a/src/App/src/Entity/OAuthAccessToken.php b/src/App/src/Entity/OAuthAccessToken.php index 01c2d90..6e7c504 100644 --- a/src/App/src/Entity/OAuthAccessToken.php +++ b/src/App/src/Entity/OAuthAccessToken.php @@ -4,6 +4,7 @@ namespace Api\App\Entity; +use Api\App\Repository\OAuthAccessTokenRepository; use DateTimeImmutable; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; @@ -19,44 +20,35 @@ use League\OAuth2\Server\Entities\ScopeEntityInterface; use RuntimeException; -/** - * @ORM\Entity(repositoryClass="Api\App\Repository\OAuthAccessTokenRepository") - * @ORM\Table(name="oauth_access_tokens") - */ +#[ORM\Entity(repositoryClass: OAuthAccessTokenRepository::class)] +#[ORM\Table(name: "oauth_access_tokens")] class OAuthAccessToken implements AccessTokenEntityInterface { - /** - * @ORM\Id() - * @ORM\Column(name="id", type="integer", options={"unsigned":true}) - * @ORM\GeneratedValue(strategy="IDENTITY") - */ + #[ORM\Id] + #[ORM\Column(name: "id", type: "integer", options: ['unsigned' => true])] + #[ORM\GeneratedValue(strategy: "IDENTITY")] private int $id; - /** - * @ORM\ManyToOne(targetEntity="Api\App\Entity\OAuthClient") - * @ORM\JoinColumn(name="client_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: OAuthClient::class)] + #[ORM\JoinColumn(name: "client_id", referencedColumnName: "id")] private ClientEntityInterface $client; - /** @ORM\Column(name="user_id", type="string", nullable=true) */ + #[ORM\Column(name: "user_id", type: "string", nullable: true)] private ?string $userId; - /** @ORM\Column(name="token", type="string", length=100) */ + #[ORM\Column(name: "token", type: "string", length: 100)] private string $token; - /** @ORM\Column(name="revoked", type="boolean", options={"default":0}) */ + #[ORM\Column(name: "revoked", type: "boolean", options: ['default' => false])] private bool $isRevoked = false; - /** - * @ORM\ManyToMany(targetEntity="Api\App\Entity\OAuthScope", inversedBy="accessTokens", indexBy="id") - * @ORM\JoinTable(name="oauth_access_token_scopes", - * joinColumns={@ORM\JoinColumn(name="access_token_id", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")} - * ) - */ + #[ORM\ManyToMany(targetEntity: OAuthScope::class, inversedBy: "accessTokens", indexBy: "id")] + #[ORM\JoinTable(name: "oauth_access_token_scopes")] + #[ORM\JoinColumn(name: "access_token_id", referencedColumnName: "id")] + #[ORM\InverseJoinColumn(name: "scope_id", referencedColumnName: "id")] protected Collection $scopes; - /** @ORM\Column(name="expires_at", type="datetime_immutable") */ + #[ORM\Column(name: 'expires_at', type: "datetime_immutable")] private DateTimeImmutable $expiresAt; private ?CryptKey $privateKey = null; diff --git a/src/App/src/Entity/OAuthAuthCode.php b/src/App/src/Entity/OAuthAuthCode.php index 5f8b758..b7749a0 100644 --- a/src/App/src/Entity/OAuthAuthCode.php +++ b/src/App/src/Entity/OAuthAuthCode.php @@ -4,6 +4,7 @@ namespace Api\App\Entity; +use Api\App\Repository\OAuthAuthCodeRepository; use DateTimeImmutable; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; @@ -14,40 +15,31 @@ use League\OAuth2\Server\Entities\ScopeEntityInterface; use League\OAuth2\Server\Entities\Traits\AuthCodeTrait; -/** - * @ORM\Entity(repositoryClass="Api\App\Repository\OAuthAuthCodeRepository") - * @ORM\Table(name="oauth_auth_codes") - */ +#[ORM\Entity(repositoryClass: OAuthAuthCodeRepository::class)] +#[ORM\Table(name: "oauth_auth_codes")] class OAuthAuthCode implements AuthCodeEntityInterface { use AuthCodeTrait; - /** - * @ORM\Id() - * @ORM\Column(name="id", type="integer", options={"unsigned":true}) - * @ORM\GeneratedValue(strategy="IDENTITY") - */ + #[ORM\Id] + #[ORM\Column(name: "id", type: "integer", options: ['unsigned' => true])] + #[ORM\GeneratedValue(strategy: "IDENTITY")] private int $id; - /** - * @ORM\ManyToOne(targetEntity="Api\App\Entity\OAuthClient") - * @ORM\JoinColumn(name="client_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: OAuthClient::class)] + #[ORM\JoinColumn(name: "client_id", referencedColumnName: "id")] private ClientEntityInterface $client; - /** @ORM\Column(name="revoked", type="boolean", options={"default":0}) */ + #[ORM\Column(name: "revoked", type: "boolean", options: ['default' => false])] private bool $isRevoked = false; - /** - * @ORM\ManyToMany(targetEntity="Api\App\Entity\OAuthSCope", inversedBy="authCodes", indexBy="id") - * @ORM\JoinTable(name="oauth_auth_code_scopes", - * joinColumns={@ORM\JoinColumn(name="auth_code_id", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")} - * ) - */ + #[ORM\ManyToMany(targetEntity: OAuthScope::class, inversedBy: "authCodes", indexBy: "id")] + #[ORM\JoinTable(name: "oauth_auth_code_scopes")] + #[ORM\JoinColumn(name: "auth_code_id", referencedColumnName: "id")] + #[ORM\InverseJoinColumn(name: "scope_id", referencedColumnName: "id")] protected Collection $scopes; - /** @ORM\Column(type="datetime_immutable", nullable=true) */ + #[ORM\Column(type: "datetime_immutable", nullable: true)] private DateTimeImmutable $expiresDatetime; public function __construct() diff --git a/src/App/src/Entity/OAuthClient.php b/src/App/src/Entity/OAuthClient.php index 0d1af8d..0ef5ab0 100644 --- a/src/App/src/Entity/OAuthClient.php +++ b/src/App/src/Entity/OAuthClient.php @@ -4,45 +4,40 @@ namespace Api\App\Entity; +use Api\App\Repository\OAuthClientRepository; use Api\User\Entity\User; use Doctrine\ORM\Mapping as ORM; use League\OAuth2\Server\Entities\ClientEntityInterface; -/** - * @ORM\Entity(repositoryClass="Api\App\Repository\OAuthClientRepository") - * @ORM\Table(name="oauth_clients") - */ +#[ORM\Entity(repositoryClass: OAuthClientRepository::class)] +#[ORM\Table(name: "oauth_clients")] class OAuthClient implements ClientEntityInterface { public const NAME_ADMIN = 'admin'; public const NAME_FRONTEND = 'frontend'; - /** - * @ORM\Id() - * @ORM\Column(name="id", type="integer", options={"unsigned":true}) - * @ORM\GeneratedValue(strategy="IDENTITY") - */ + #[ORM\Id] + #[ORM\Column(name: "id", type: "integer", options: ['unsigned' => true])] + #[ORM\GeneratedValue(strategy: "IDENTITY")] private int $id; - /** - * @ORM\ManyToOne(targetEntity="Api\User\Entity\User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="uuid", nullable=true) - */ + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(name: "user_id", referencedColumnName: "uuid", nullable: true)] private ?User $user = null; - /** @ORM\Column(name="name", type="string", length=40) */ + #[ORM\Column(name: "name", type: "string", length: 40)] private string $name = ''; - /** @ORM\Column(name="secret", type="string", length=100, nullable=true) */ + #[ORM\Column(name: "secret", type: "string", length: 100, nullable: true)] private ?string $secret = null; - /** @ORM\Column(name="redirect", type="string", length=191) */ + #[ORM\Column(name: "redirect", type: "string", length: 191)] private string $redirect = ''; - /** @ORM\Column(name="revoked", type="boolean", options={"default":0}) */ + #[ORM\Column(name: "revoked", type: "boolean", options: ['default' => false])] private bool $isRevoked = false; - /** @ORM\Column(name="isConfidential", type="boolean", options={"default":0}) */ + #[ORM\Column(name: "isConfidential", type: "boolean", options: ['default' => false])] private bool $isConfidential = false; public function setId(int $id): self diff --git a/src/App/src/Entity/OAuthRefreshToken.php b/src/App/src/Entity/OAuthRefreshToken.php index 1649bfe..554fe1c 100644 --- a/src/App/src/Entity/OAuthRefreshToken.php +++ b/src/App/src/Entity/OAuthRefreshToken.php @@ -4,34 +4,29 @@ namespace Api\App\Entity; +use Api\App\Repository\OAuthRefreshTokenRepository; use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; use League\OAuth2\Server\Entities\AccessTokenEntityInterface; use League\OAuth2\Server\Entities\RefreshTokenEntityInterface; -/** - * @ORM\Entity(repositoryClass="Api\App\Repository\OAuthRefreshTokenRepository") - * @ORM\Table(name="oauth_refresh_tokens") - */ +#[ORM\Entity(repositoryClass: OAuthRefreshTokenRepository::class)] +#[ORM\Table(name: "oauth_refresh_tokens")] class OAuthRefreshToken implements RefreshTokenEntityInterface { - /** - * @ORM\Id() - * @ORM\Column(name="id", type="integer", options={"unsigned":true}) - * @ORM\GeneratedValue(strategy="IDENTITY") - */ + #[ORM\Id] + #[ORM\Column(name: "id", type: "integer", options: ['unsigned' => true])] + #[ORM\GeneratedValue(strategy: "IDENTITY")] private int $id; - /** - * @ORM\ManyToOne(targetEntity="Api\App\Entity\OAuthAccessToken") - * @ORM\JoinColumn(name="access_token_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: OAuthAccessToken::class)] + #[ORM\JoinColumn(name: "access_token_id", referencedColumnName: "id")] private AccessTokenEntityInterface $accessToken; - /** @ORM\Column(name="revoked", type="boolean", options={"default":0}) */ + #[ORM\Column(name: "revoked", type: "boolean", options: ['default' => false])] private bool $isRevoked = false; - /** @ORM\Column(name="expires_at", type="datetime_immutable") */ + #[ORM\Column(name: "expires_at", type: "datetime_immutable")] private DateTimeImmutable $expiresAt; public function setId(int $id): self diff --git a/src/App/src/Entity/OAuthScope.php b/src/App/src/Entity/OAuthScope.php index 5a8192a..47b88b5 100644 --- a/src/App/src/Entity/OAuthScope.php +++ b/src/App/src/Entity/OAuthScope.php @@ -4,6 +4,7 @@ namespace Api\App\Entity; +use Api\App\Repository\OAuthScopeRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; @@ -11,28 +12,24 @@ use League\OAuth2\Server\Entities\ScopeEntityInterface; use League\OAuth2\Server\Entities\Traits\ScopeTrait; -/** - * @ORM\Entity(repositoryClass="Api\App\Repository\OAuthScopeRepository") - * @ORM\Table(name="oauth_scopes") - */ +#[ORM\Entity(repositoryClass: OAuthScopeRepository::class)] +#[ORM\Table(name: "oauth_scopes")] class OAuthScope implements ScopeEntityInterface { use ScopeTrait; - /** - * @ORM\Id() - * @ORM\Column(name="id", type="integer", options={"unsigned":true}) - * @ORM\GeneratedValue(strategy="IDENTITY") - */ + #[ORM\Id] + #[ORM\Column(name: "id", type: "integer", options: ['unsigned' => true])] + #[ORM\GeneratedValue(strategy: "IDENTITY")] private int $id; - /** @ORM\Column(name="scope", type="string", length=191) */ + #[ORM\Column(name: "scope", type: "string", length: 191)] private string $scope = ''; - /** @ORM\ManyToMany(targetEntity="Api\App\Entity\OAuthAccessToken", mappedBy="scopes") */ + #[ORM\ManyToMany(targetEntity: OAuthAccessToken::class, mappedBy: "scopes")] protected Collection $accessTokens; - /** @ORM\ManyToMany(targetEntity="Api\App\Entity\OAuthAuthCode", mappedBy="scopes") */ + #[ORM\ManyToMany(targetEntity: OAuthAuthCode::class, mappedBy: "scopes")] protected Collection $authCodes; public function __construct() diff --git a/src/App/src/Entity/TimestampAwareTrait.php b/src/App/src/Entity/TimestampAwareTrait.php index d1874db..e5869ba 100644 --- a/src/App/src/Entity/TimestampAwareTrait.php +++ b/src/App/src/Entity/TimestampAwareTrait.php @@ -11,16 +11,14 @@ trait TimestampAwareTrait { private string $dateFormat = 'Y-m-d H:i:s'; - /** @ORM\Column(name="created", type="datetime_immutable") */ + #[ORM\Column(name: "created", type: "datetime_immutable")] protected ?DateTimeImmutable $created; - /** @ORM\Column(name="updated", type="datetime_immutable", nullable=true) */ + #[ORM\Column(name: "updated", type: "datetime_immutable", nullable: true)] protected ?DateTimeImmutable $updated; - /** - * @ORM\PrePersist() - * @ORM\PreUpdate() - */ + #[ORM\PrePersist] + #[ORM\PreUpdate] public function updateTimestamps(): void { $this->touch(); diff --git a/src/App/src/Entity/UuidAwareTrait.php b/src/App/src/Entity/UuidAwareTrait.php index 72d7398..9e31662 100644 --- a/src/App/src/Entity/UuidAwareTrait.php +++ b/src/App/src/Entity/UuidAwareTrait.php @@ -9,12 +9,10 @@ trait UuidAwareTrait { - /** - * @ORM\Id() - * @ORM\Column(name="uuid", type="uuid_binary_ordered_time", unique=true) - * @ORM\GeneratedValue(strategy="CUSTOM") - * @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidOrderedTimeGenerator") - */ + #[ORM\Id] + #[ORM\Column(name: 'uuid', type: "uuid_binary_ordered_time", unique: true)] + #[ORM\GeneratedValue(strategy: "CUSTOM")] + #[ORM\CustomIdGenerator(\Ramsey\Uuid\Doctrine\UuidOrderedTimeGenerator::class)] protected ?UuidInterface $uuid; public function getUuid(): ?UuidInterface diff --git a/src/User/src/Entity/User.php b/src/User/src/Entity/User.php index 67aa64f..255b12f 100644 --- a/src/User/src/Entity/User.php +++ b/src/User/src/Entity/User.php @@ -8,6 +8,7 @@ use Api\App\Entity\PasswordTrait; use Api\App\Entity\RoleInterface; use Api\App\Entity\UuidOrderedTimeGenerator; +use Api\User\Repository\UserRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -17,11 +18,9 @@ use function bin2hex; use function random_bytes; -/** - * @ORM\Entity(repositoryClass="Api\User\Repository\UserRepository") - * @ORM\Table(name="user") - * @ORM\HasLifecycleCallbacks() - */ +#[ORM\Entity(repositoryClass: UserRepository::class)] +#[ORM\Table(name: "user")] +#[ORM\HasLifecycleCallbacks] class User extends AbstractEntity implements UserEntityInterface { use PasswordTrait; @@ -33,38 +32,34 @@ class User extends AbstractEntity implements UserEntityInterface self::STATUS_ACTIVE, ]; - /** @ORM\OneToOne(targetEntity="UserAvatar", cascade={"persist", "remove"}, mappedBy="user") */ + #[ORM\OneToOne(mappedBy: "user", targetEntity: UserAvatar::class, cascade: ['persist', 'remove'])] protected ?UserAvatar $avatar = null; - /** @ORM\OneToOne(targetEntity="UserDetail", cascade={"persist", "remove"}, mappedBy="user") */ + #[ORM\OneToOne(mappedBy: "user", targetEntity: UserDetail::class, cascade: ['persist', 'remove'])] protected UserDetail $detail; - /** @ORM\OneToMany(targetEntity="UserResetPasswordEntity", cascade={"persist", "remove"}, mappedBy="user") */ + #[ORM\OneToMany(mappedBy: "user", targetEntity: UserResetPasswordEntity::class, cascade: ['persist', 'remove'])] protected Collection $resetPasswords; - /** - * @ORM\ManyToMany(targetEntity="UserRole") - * @ORM\JoinTable( - * name="user_roles", - * joinColumns={@ORM\JoinColumn(name="userUuid", referencedColumnName="uuid")}, - * inverseJoinColumns={@ORM\JoinColumn(name="roleUuid", referencedColumnName="uuid")} - * ) - */ + #[ORM\ManyToMany(targetEntity: UserRole::class)] + #[ORM\JoinTable(name: "user_roles")] + #[ORM\JoinColumn(name: "userUuid", referencedColumnName: "uuid")] + #[ORM\InverseJoinColumn(name: "roleUuid", referencedColumnName: "uuid")] protected Collection $roles; - /** @ORM\Column(name="identity", type="string", length=191, unique=true) */ + #[ORM\Column(name: "identity", type: "string", length: 191, unique: true)] protected string $identity; - /** @ORM\Column(name="password", type="string", length=191) */ + #[ORM\Column(name: "password", type: "string", length: 191)] protected string $password; - /** @ORM\Column(name="status", type="string", length=20) */ + #[ORM\Column("status", type: "string", length: 20)] protected string $status = self::STATUS_PENDING; - /** @ORM\Column(name="isDeleted", type="boolean") */ + #[ORM\Column("isDeleted", type: "boolean")] protected bool $isDeleted = false; - /** @ORM\Column(name="hash", type="string", length=64, unique=true) */ + #[ORM\Column(name: "hash", type: "string", length: 64, unique: true)] protected string $hash; public function __construct() diff --git a/src/User/src/Entity/UserAvatar.php b/src/User/src/Entity/UserAvatar.php index 11d8b25..165fa77 100644 --- a/src/User/src/Entity/UserAvatar.php +++ b/src/User/src/Entity/UserAvatar.php @@ -6,23 +6,20 @@ use Api\App\Entity\AbstractEntity; use Api\User\EventListener\UserAvatarEventListener; +use Api\User\Repository\UserAvatarRepository; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity(repositoryClass="Api\User\Repository\UserAvatarRepository") - * @ORM\Table(name="user_avatar") - * @ORM\HasLifecycleCallbacks() - * @ORM\EntityListeners({UserAvatarEventListener::class}) - */ +#[ORM\Entity(repositoryClass: UserAvatarRepository::class)] +#[ORM\Table(name: "user_avatar")] +#[ORM\HasLifecycleCallbacks] +#[ORM\EntityListeners([UserAvatarEventListener::class])] class UserAvatar extends AbstractEntity { - /** - * @ORM\OneToOne(targetEntity="User", inversedBy="avatar") - * @ORM\JoinColumn(name="userUuid", referencedColumnName="uuid") - */ + #[ORM\OneToOne(inversedBy: "avatar", targetEntity: User::class)] + #[ORM\JoinColumn(name: "userUuid", referencedColumnName: "uuid")] protected User $user; - /** @ORM\Column(name="name", type="string", length=191) */ + #[ORM\Column(name: "name", type: "string", length: 191)] protected string $name; protected ?string $url = null; diff --git a/src/User/src/Entity/UserDetail.php b/src/User/src/Entity/UserDetail.php index e6a02c0..e3633c9 100644 --- a/src/User/src/Entity/UserDetail.php +++ b/src/User/src/Entity/UserDetail.php @@ -5,28 +5,25 @@ namespace Api\User\Entity; use Api\App\Entity\AbstractEntity; +use Api\User\Repository\UserDetailRepository; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity(repositoryClass="Api\User\Repository\UserDetailRepository") - * @ORM\Table(name="user_detail") - * @ORM\HasLifecycleCallbacks() - */ +#[ORM\Entity(repositoryClass: UserDetailRepository::class)] +#[ORM\Table(name: "user_detail")] +#[ORM\HasLifecycleCallbacks] class UserDetail extends AbstractEntity { - /** - * @ORM\OneToOne(targetEntity="User", inversedBy="detail") - * @ORM\JoinColumn(name="userUuid", referencedColumnName="uuid") - */ + #[ORM\OneToOne(inversedBy: "detail", targetEntity: User::class)] + #[ORM\JoinColumn(name: "userUuid", referencedColumnName: "uuid")] protected User $user; - /** @ORM\Column(name="firstName", type="string", length=191, nullable=true) */ + #[ORM\Column(name: "firstName", type: "string", length: 191, nullable: true)] protected ?string $firstName = null; - /** @ORM\Column(name="lastName", type="string", length=191, nullable=true) */ + #[ORM\Column(name: "lastName", type: "string", length: 191, nullable: true)] protected ?string $lastName = null; - /** @ORM\Column(name="email", type="string", length=191) */ + #[ORM\Column(name: "email", type: "string", length: 191)] protected string $email; public function getUser(): User diff --git a/src/User/src/Entity/UserResetPasswordEntity.php b/src/User/src/Entity/UserResetPasswordEntity.php index 4b10da6..fe011da 100644 --- a/src/User/src/Entity/UserResetPasswordEntity.php +++ b/src/User/src/Entity/UserResetPasswordEntity.php @@ -11,11 +11,7 @@ use Doctrine\ORM\Mapping as ORM; use Throwable; -/** - * @ORM\Entity() - * @ORM\Table(name="user_reset_password") - * @ORM\HasLifecycleCallbacks() - */ +#[ORM\Entity, ORM\Table(name: "user_reset_password"), ORM\HasLifecycleCallbacks] class UserResetPasswordEntity extends AbstractEntity { public const STATUS_COMPLETED = 'completed'; @@ -25,19 +21,17 @@ class UserResetPasswordEntity extends AbstractEntity self::STATUS_REQUESTED, ]; - /** - * @ORM\ManyToOne(targetEntity="User", cascade={"persist", "remove"}, inversedBy="resetPasswords") - * @ORM\JoinColumn(name="userUuid", referencedColumnName="uuid") - */ + #[ORM\ManyToOne(targetEntity: "User", cascade: ['persist', 'remove'], inversedBy: "resetPasswords")] + #[ORM\JoinColumn(name: "userUuid", referencedColumnName: "uuid")] protected User $user; - /** @ORM\Column(name="expires", type="datetime_immutable") */ + #[ORM\Column(name: "expires", type: "datetime_immutable")] protected DateTimeImmutable $expires; - /** @ORM\Column(name="hash", type="string", length=64, unique=true) */ + #[ORM\Column(name: "hash", type: "string", length: 64, unique: true)] protected string $hash; - /** @ORM\Column(name="status", type="string", length=20) */ + #[ORM\Column(name: "status", type: "string", length: 20)] protected string $status = self::STATUS_REQUESTED; public function __construct() diff --git a/src/User/src/Entity/UserRole.php b/src/User/src/Entity/UserRole.php index 7d6a3c9..1bf9c1a 100644 --- a/src/User/src/Entity/UserRole.php +++ b/src/User/src/Entity/UserRole.php @@ -6,23 +6,24 @@ use Api\App\Entity\AbstractEntity; use Api\App\Entity\RoleInterface; +use Api\User\Repository\UserRoleRepository; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity(repositoryClass="Api\User\Repository\UserRoleRepository") - * @ORM\Table(name="user_role") - * @ORM\HasLifecycleCallbacks() - */ +#[ORM\Entity(repositoryClass: UserRoleRepository::class)] +#[ORM\Table(name: "user_role")] +#[ORM\HasLifecycleCallbacks] class UserRole extends AbstractEntity implements RoleInterface { - public const ROLE_GUEST = 'guest'; - public const ROLE_USER = 'user'; - public const ROLES = [ + public const ROLE_GUEST = 'guest'; + public const ROLE_API_USER = 'api_user'; + public const ROLE_USER = 'user'; + public const ROLES = [ self::ROLE_GUEST, + self::ROLE_API_USER, self::ROLE_USER, ]; - /** @ORM\Column(name="name", type="string", length=20, unique=true) */ + #[ORM\Column(name: "name", type: "string", length: 20, unique: true)] protected string $name; public function getName(): string From 98f417f164a23c86abd387e928c35f740cd3f2e3 Mon Sep 17 00:00:00 2001 From: claudiu Date: Wed, 1 Nov 2023 11:49:44 +0200 Subject: [PATCH 2/2] changes for pull request review --- src/User/src/Entity/User.php | 4 ++-- src/User/src/Entity/UserResetPasswordEntity.php | 6 ++++-- src/User/src/Entity/UserRole.php | 8 +++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/User/src/Entity/User.php b/src/User/src/Entity/User.php index 255b12f..0bfdc56 100644 --- a/src/User/src/Entity/User.php +++ b/src/User/src/Entity/User.php @@ -53,10 +53,10 @@ class User extends AbstractEntity implements UserEntityInterface #[ORM\Column(name: "password", type: "string", length: 191)] protected string $password; - #[ORM\Column("status", type: "string", length: 20)] + #[ORM\Column(name: "status", type: "string", length: 20)] protected string $status = self::STATUS_PENDING; - #[ORM\Column("isDeleted", type: "boolean")] + #[ORM\Column(name: "isDeleted", type: "boolean")] protected bool $isDeleted = false; #[ORM\Column(name: "hash", type: "string", length: 64, unique: true)] diff --git a/src/User/src/Entity/UserResetPasswordEntity.php b/src/User/src/Entity/UserResetPasswordEntity.php index fe011da..e14ae9a 100644 --- a/src/User/src/Entity/UserResetPasswordEntity.php +++ b/src/User/src/Entity/UserResetPasswordEntity.php @@ -11,7 +11,9 @@ use Doctrine\ORM\Mapping as ORM; use Throwable; -#[ORM\Entity, ORM\Table(name: "user_reset_password"), ORM\HasLifecycleCallbacks] +#[ORM\Entity] +#[ORM\Table(name: "user_reset_password")] +#[ORM\HasLifecycleCallbacks] class UserResetPasswordEntity extends AbstractEntity { public const STATUS_COMPLETED = 'completed'; @@ -21,7 +23,7 @@ class UserResetPasswordEntity extends AbstractEntity self::STATUS_REQUESTED, ]; - #[ORM\ManyToOne(targetEntity: "User", cascade: ['persist', 'remove'], inversedBy: "resetPasswords")] + #[ORM\ManyToOne(targetEntity: User::class, cascade: ['persist', 'remove'], inversedBy: "resetPasswords")] #[ORM\JoinColumn(name: "userUuid", referencedColumnName: "uuid")] protected User $user; diff --git a/src/User/src/Entity/UserRole.php b/src/User/src/Entity/UserRole.php index 1bf9c1a..9897a7b 100644 --- a/src/User/src/Entity/UserRole.php +++ b/src/User/src/Entity/UserRole.php @@ -14,12 +14,10 @@ #[ORM\HasLifecycleCallbacks] class UserRole extends AbstractEntity implements RoleInterface { - public const ROLE_GUEST = 'guest'; - public const ROLE_API_USER = 'api_user'; - public const ROLE_USER = 'user'; - public const ROLES = [ + public const ROLE_GUEST = 'guest'; + public const ROLE_USER = 'user'; + public const ROLES = [ self::ROLE_GUEST, - self::ROLE_API_USER, self::ROLE_USER, ];