['project:write', 'project:create']], ), new Patch(security: "is_granted('ROLE_ADMIN')"), new Delete(security: "is_granted('ROLE_ADMIN')"), ], normalizationContext: ['groups' => ['project:read']], denormalizationContext: ['groups' => ['project:write']], order: ['name' => 'ASC'], )] #[ORM\Entity(repositoryClass: ProjectRepository::class)] #[UniqueEntity(fields: ['code'], message: 'Ce code de projet est déjà utilisé.')] class Project { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(['project:read', 'time_entry:read', 'task:read'])] private ?int $id = null; #[ORM\Column(length: 10, unique: true)] #[Groups(['project:read', 'project:create', 'task:read'])] #[Assert\NotBlank] #[Assert\Regex(pattern: '/^[A-Z]{2,10}$/', message: 'Le code doit contenir entre 2 et 10 lettres majuscules.')] private ?string $code = null; #[ORM\Column(length: 255)] #[Groups(['project:read', 'project:write', 'time_entry:read'])] private ?string $name = null; #[ORM\Column(type: 'text', nullable: true)] #[Groups(['project:read', 'project:write'])] private ?string $description = null; #[ORM\Column(length: 7)] #[Groups(['project:read', 'project:write', 'time_entry:read'])] private ?string $color = '#222783'; #[ORM\ManyToOne(targetEntity: Client::class, inversedBy: 'projects')] #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] #[Groups(['project:read', 'project:write'])] private ?Client $client = null; #[ORM\Column(length: 255, nullable: true)] #[Groups(['project:read', 'project:write', 'task:read'])] private ?string $giteaOwner = null; #[ORM\Column(length: 255, nullable: true)] #[Groups(['project:read', 'project:write', 'task:read'])] private ?string $giteaRepo = null; public function getId(): ?int { return $this->id; } public function getCode(): ?string { return $this->code; } public function setCode(string $code): static { $this->code = $code; return $this; } public function getName(): ?string { return $this->name; } public function setName(string $name): static { $this->name = $name; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): static { $this->description = $description; return $this; } public function getColor(): ?string { return $this->color; } public function setColor(string $color): static { $this->color = $color; return $this; } public function getClient(): ?Client { return $this->client; } public function setClient(?Client $client): static { $this->client = $client; return $this; } public function getGiteaOwner(): ?string { return $this->giteaOwner; } public function setGiteaOwner(?string $giteaOwner): static { $this->giteaOwner = $giteaOwner; return $this; } public function getGiteaRepo(): ?string { return $this->giteaRepo; } public function setGiteaRepo(?string $giteaRepo): static { $this->giteaRepo = $giteaRepo; return $this; } public function hasGiteaRepo(): bool { return null !== $this->giteaOwner && null !== $this->giteaRepo; } }