From d70925b812a1eca8726843aa91d8264bc7eb5981 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Fri, 19 Jun 2026 16:04:14 +0200 Subject: [PATCH] refactor(core) : point user relations to the shared contract via resolve_target_entities --- src/Entity/AbsenceBalance.php | 9 +++++---- src/Entity/AbsenceRequest.php | 17 +++++++++-------- src/Entity/Notification.php | 9 +++++---- src/Entity/Task.php | 19 ++++++++++--------- src/Entity/TaskDocument.php | 9 +++++---- src/Entity/TaskMailLink.php | 9 +++++---- src/Entity/TimeEntry.php | 9 +++++---- 7 files changed, 44 insertions(+), 37 deletions(-) diff --git a/src/Entity/AbsenceBalance.php b/src/Entity/AbsenceBalance.php index 97efea9..9164973 100644 --- a/src/Entity/AbsenceBalance.php +++ b/src/Entity/AbsenceBalance.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Patch; use App\Enum\AbsenceType; use App\Repository\AbsenceBalanceRepository; +use App\Shared\Domain\Contract\UserInterface; use App\State\AbsenceBalanceProvider; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; @@ -45,10 +46,10 @@ class AbsenceBalance #[Groups(['absence_balance:read'])] private ?int $id = null; - #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\ManyToOne(targetEntity: UserInterface::class)] #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] #[Groups(['absence_balance:read'])] - private ?User $user = null; + private ?UserInterface $user = null; #[ORM\Column(type: Types::STRING, length: 32, enumType: AbsenceType::class)] #[Groups(['absence_balance:read'])] @@ -110,12 +111,12 @@ class AbsenceBalance return $this->id; } - public function getUser(): ?User + public function getUser(): ?UserInterface { return $this->user; } - public function setUser(?User $user): static + public function setUser(?UserInterface $user): static { $this->user = $user; diff --git a/src/Entity/AbsenceRequest.php b/src/Entity/AbsenceRequest.php index 5045bdf..7daefd8 100644 --- a/src/Entity/AbsenceRequest.php +++ b/src/Entity/AbsenceRequest.php @@ -14,6 +14,7 @@ use App\Enum\AbsenceStatus; use App\Enum\AbsenceType; use App\Enum\HalfDay; use App\Repository\AbsenceRequestRepository; +use App\Shared\Domain\Contract\UserInterface; use App\State\AbsenceCancelProcessor; use App\State\AbsenceRequestProcessor; use App\State\AbsenceRequestProvider; @@ -73,10 +74,10 @@ class AbsenceRequest #[Groups(['absence_request:read'])] private ?int $id = null; - #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\ManyToOne(targetEntity: UserInterface::class)] #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] #[Groups(['absence_request:read'])] - private ?User $user = null; + private ?UserInterface $user = null; #[ORM\Column(type: Types::STRING, length: 32, enumType: AbsenceType::class)] #[Groups(['absence_request:read', 'absence_request:write'])] @@ -130,10 +131,10 @@ class AbsenceRequest #[Groups(['absence_request:read'])] private ?DateTimeImmutable $reviewedAt = null; - #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\ManyToOne(targetEntity: UserInterface::class)] #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] #[Groups(['absence_request:read'])] - private ?User $reviewedBy = null; + private ?UserInterface $reviewedBy = null; #[Groups(['absence_request:read'])] public function getLabel(): ?string @@ -156,12 +157,12 @@ class AbsenceRequest return $this->id; } - public function getUser(): ?User + public function getUser(): ?UserInterface { return $this->user; } - public function setUser(?User $user): static + public function setUser(?UserInterface $user): static { $this->user = $user; @@ -312,12 +313,12 @@ class AbsenceRequest return $this; } - public function getReviewedBy(): ?User + public function getReviewedBy(): ?UserInterface { return $this->reviewedBy; } - public function setReviewedBy(?User $reviewedBy): static + public function setReviewedBy(?UserInterface $reviewedBy): static { $this->reviewedBy = $reviewedBy; diff --git a/src/Entity/Notification.php b/src/Entity/Notification.php index 2253335..601c0a0 100644 --- a/src/Entity/Notification.php +++ b/src/Entity/Notification.php @@ -8,6 +8,7 @@ use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Patch; use App\Repository\NotificationRepository; +use App\Shared\Domain\Contract\UserInterface; use App\State\NotificationProvider; use DateTimeImmutable; use Doctrine\DBAL\Types\Types; @@ -39,10 +40,10 @@ class Notification #[Groups(['notification:read'])] private ?int $id = null; - #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\ManyToOne(targetEntity: UserInterface::class)] #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] #[Groups(['notification:read'])] - private ?User $user = null; + private ?UserInterface $user = null; #[ORM\Column(length: 50)] #[Groups(['notification:read'])] @@ -69,12 +70,12 @@ class Notification return $this->id; } - public function getUser(): ?User + public function getUser(): ?UserInterface { return $this->user; } - public function setUser(?User $user): static + public function setUser(?UserInterface $user): static { $this->user = $user; diff --git a/src/Entity/Task.php b/src/Entity/Task.php index 984dc15..4346a37 100644 --- a/src/Entity/Task.php +++ b/src/Entity/Task.php @@ -16,6 +16,7 @@ use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Post; use App\Repository\TaskRepository; +use App\Shared\Domain\Contract\UserInterface; use App\State\TaskCalendarProcessor; use App\State\TaskNumberProcessor; use DateTimeImmutable; @@ -80,13 +81,13 @@ class Task #[Groups(['task:read', 'task:write'])] private ?TaskPriority $priority = null; - #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\ManyToOne(targetEntity: UserInterface::class)] #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] #[Groups(['task:read', 'task:write'])] - private ?User $assignee = null; + private ?UserInterface $assignee = null; - /** @var Collection */ - #[ORM\ManyToMany(targetEntity: User::class)] + /** @var Collection */ + #[ORM\ManyToMany(targetEntity: UserInterface::class)] #[ORM\JoinTable( name: 'task_collaborator', joinColumns: [new ORM\JoinColumn(name: 'task_id', referencedColumnName: 'id', onDelete: 'CASCADE')], @@ -239,25 +240,25 @@ class Task return $this; } - public function getAssignee(): ?User + public function getAssignee(): ?UserInterface { return $this->assignee; } - public function setAssignee(?User $assignee): static + public function setAssignee(?UserInterface $assignee): static { $this->assignee = $assignee; return $this; } - /** @return Collection */ + /** @return Collection */ public function getCollaborators(): Collection { return $this->collaborators; } - public function addCollaborator(User $user): static + public function addCollaborator(UserInterface $user): static { if (!$this->collaborators->contains($user)) { $this->collaborators->add($user); @@ -266,7 +267,7 @@ class Task return $this; } - public function removeCollaborator(User $user): static + public function removeCollaborator(UserInterface $user): static { $this->collaborators->removeElement($user); diff --git a/src/Entity/TaskDocument.php b/src/Entity/TaskDocument.php index 5e1d5f0..235fc14 100644 --- a/src/Entity/TaskDocument.php +++ b/src/Entity/TaskDocument.php @@ -12,6 +12,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Post; use App\EventListener\TaskDocumentListener; +use App\Shared\Domain\Contract\UserInterface; use App\State\TaskDocumentProcessor; use App\State\TaskDocumentProvider; use DateTimeImmutable; @@ -77,10 +78,10 @@ class TaskDocument #[Groups(['task_document:read', 'task:read'])] private ?DateTimeImmutable $createdAt = null; - #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\ManyToOne(targetEntity: UserInterface::class)] #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] #[Groups(['task_document:read', 'task:read'])] - private ?User $uploadedBy = null; + private ?UserInterface $uploadedBy = null; public function getId(): ?int { @@ -176,12 +177,12 @@ class TaskDocument return $this; } - public function getUploadedBy(): ?User + public function getUploadedBy(): ?UserInterface { return $this->uploadedBy; } - public function setUploadedBy(?User $uploadedBy): static + public function setUploadedBy(?UserInterface $uploadedBy): static { $this->uploadedBy = $uploadedBy; diff --git a/src/Entity/TaskMailLink.php b/src/Entity/TaskMailLink.php index 652fc22..041efcb 100644 --- a/src/Entity/TaskMailLink.php +++ b/src/Entity/TaskMailLink.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Entity; use App\Repository\TaskMailLinkRepository; +use App\Shared\Domain\Contract\UserInterface; use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; @@ -29,9 +30,9 @@ class TaskMailLink #[ORM\Column(type: 'datetimetz_immutable')] private DateTimeImmutable $linkedAt; - #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\ManyToOne(targetEntity: UserInterface::class)] #[ORM\JoinColumn(name: 'linked_by_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')] - private ?User $linkedBy = null; + private ?UserInterface $linkedBy = null; public function getId(): ?int { @@ -74,12 +75,12 @@ class TaskMailLink return $this; } - public function getLinkedBy(): ?User + public function getLinkedBy(): ?UserInterface { return $this->linkedBy; } - public function setLinkedBy(?User $linkedBy): static + public function setLinkedBy(?UserInterface $linkedBy): static { $this->linkedBy = $linkedBy; diff --git a/src/Entity/TimeEntry.php b/src/Entity/TimeEntry.php index b6c68a3..6b6e724 100644 --- a/src/Entity/TimeEntry.php +++ b/src/Entity/TimeEntry.php @@ -14,6 +14,7 @@ use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Post; use App\Repository\TimeEntryRepository; +use App\Shared\Domain\Contract\UserInterface; use App\State\ActiveTimeEntryProvider; use DateTimeImmutable; use Doctrine\Common\Collections\ArrayCollection; @@ -77,10 +78,10 @@ class TimeEntry #[Groups(['time_entry:read', 'time_entry:write'])] private ?DateTimeImmutable $stoppedAt = null; - #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\ManyToOne(targetEntity: UserInterface::class)] #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] #[Groups(['time_entry:read', 'time_entry:write'])] - private ?User $user = null; + private ?UserInterface $user = null; #[ORM\ManyToOne(targetEntity: Project::class)] #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] @@ -160,12 +161,12 @@ class TimeEntry return $this; } - public function getUser(): ?User + public function getUser(): ?UserInterface { return $this->user; } - public function setUser(?User $user): static + public function setUser(?UserInterface $user): static { $this->user = $user;