['app:read']], security: "is_granted('ROLE_ADMIN')", provider: ApplicationProvider::class, ), new Get( uriVariables: ['slug'], normalizationContext: ['groups' => ['app:read', 'app:detail']], security: "is_granted('ROLE_ADMIN')", provider: ApplicationProvider::class, ), new Post( security: "is_granted('ROLE_ADMIN')", ), new Patch( uriVariables: ['slug'], security: "is_granted('ROLE_ADMIN')", ), new Delete( uriVariables: ['slug'], security: "is_granted('ROLE_ADMIN')", ), ], normalizationContext: ['groups' => ['app:read']], denormalizationContext: ['groups' => ['app:write']], )] #[ORM\Entity(repositoryClass: ApplicationRepository::class)] class Application { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(['app:read'])] private ?int $id = null; #[ORM\Column(length: 255)] #[Groups(['app:read', 'app:write'])] private ?string $name = null; #[ORM\Column(length: 255, unique: true)] #[ApiProperty(identifier: true)] #[Groups(['app:read', 'app:write'])] private ?string $slug = null; #[ORM\Column(length: 255)] #[Groups(['app:read', 'app:write'])] private ?string $registryImage = null; #[ORM\Column(type: Types::TEXT, nullable: true)] #[Groups(['app:read', 'app:write'])] private ?string $description = null; #[ORM\Column(length: 255, nullable: true)] #[Groups(['app:read', 'app:write'])] private ?string $giteaUrl = null; #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] #[Groups(['app:read'])] private ?DateTimeImmutable $createdAt = null; /** @var Collection */ #[ORM\OneToMany(targetEntity: Environment::class, mappedBy: 'application', cascade: ['persist', 'remove'], orphanRemoval: true)] #[Groups(['app:read', 'app:detail'])] private Collection $environments; public function __construct() { $this->createdAt = new DateTimeImmutable(); $this->environments = 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 getSlug(): ?string { return $this->slug; } public function setSlug(string $slug): static { $this->slug = $slug; return $this; } public function getRegistryImage(): ?string { return $this->registryImage; } public function setRegistryImage(string $registryImage): static { $this->registryImage = $registryImage; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): static { $this->description = $description; return $this; } public function getGiteaUrl(): ?string { return $this->giteaUrl; } public function setGiteaUrl(?string $giteaUrl): static { $this->giteaUrl = $giteaUrl; return $this; } public function getCreatedAt(): ?DateTimeImmutable { return $this->createdAt; } /** @return Collection */ public function getEnvironments(): Collection { return $this->environments; } public function addEnvironment(Environment $environment): static { if (!$this->environments->contains($environment)) { $this->environments->add($environment); $environment->setApplication($this); } return $this; } public function removeEnvironment(Environment $environment): static { if ($this->environments->removeElement($environment)) { if ($environment->getApplication() === $this) { $environment->setApplication(null); } } return $this; } }