['workflow:read']], denormalizationContext: ['groups' => ['workflow:write']], order: ['position' => 'ASC'], )] #[ORM\Entity(repositoryClass: WorkflowRepository::class)] #[UniqueEntity(fields: ['name'], message: 'Ce nom de workflow est déjà utilisé.')] class Workflow { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(['workflow:read', 'project:read', 'task_status:read'])] private ?int $id = null; #[ORM\Column(length: 255, unique: true)] #[Groups(['workflow:read', 'workflow:write', 'project:read'])] #[Assert\NotBlank] private ?string $name = null; #[ORM\Column(type: 'boolean', options: ['default' => false])] #[Groups(['workflow:read', 'workflow:write'])] private bool $isDefault = false; #[ORM\Column(type: 'integer', options: ['default' => 0])] #[Groups(['workflow:read', 'workflow:write'])] private int $position = 0; /** @var Collection */ #[ORM\OneToMany(targetEntity: TaskStatus::class, mappedBy: 'workflow', cascade: ['persist', 'remove'], orphanRemoval: true)] #[ORM\OrderBy(['position' => 'ASC'])] #[Groups(['workflow:read', 'project:read'])] private Collection $statuses; public function __construct() { $this->statuses = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): static { $this->name = $name; return $this; } public function isDefault(): bool { return $this->isDefault; } public function setIsDefault(bool $isDefault): static { $this->isDefault = $isDefault; return $this; } public function getPosition(): int { return $this->position; } public function setPosition(int $position): static { $this->position = $position; return $this; } /** @return Collection */ public function getStatuses(): Collection { return $this->statuses; } public function addStatus(TaskStatus $status): static { if (!$this->statuses->contains($status)) { $this->statuses->add($status); $status->setWorkflow($this); } return $this; } public function removeStatus(TaskStatus $status): static { $this->statuses->removeElement($status); return $this; } }