refactor(core) : point user relations to the shared contract via resolve_target_entities

This commit is contained in:
Matthieu
2026-06-19 16:04:14 +02:00
parent f8fc4d6bd9
commit d70925b812
7 changed files with 44 additions and 37 deletions
+10 -9
View File
@@ -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<int, User> */
#[ORM\ManyToMany(targetEntity: User::class)]
/** @var Collection<int, UserInterface> */
#[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<int, User> */
/** @return Collection<int, UserInterface> */
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);