139 lines
2.9 KiB
PHP
139 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Entity;
|
|
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
use ApiPlatform\Metadata\Get;
|
|
use ApiPlatform\Metadata\GetCollection;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Attribute\Groups;
|
|
use Symfony\Component\Serializer\Attribute\SerializedName;
|
|
|
|
#[ORM\Entity]
|
|
#[ApiResource(
|
|
operations: [
|
|
new Get(
|
|
requirements: ['id' => '\d+'],
|
|
normalizationContext: ['groups' => ['building:read']],
|
|
),
|
|
new GetCollection(
|
|
normalizationContext: ['groups' => ['building:read']],
|
|
),
|
|
],
|
|
security: "is_granted('ROLE_USER')",
|
|
)]
|
|
class Statut
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
#[Groups(['building:read'])]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
#[Groups(['building:read'])]
|
|
private ?string $label = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
#[Groups(['building:read'])]
|
|
private ?string $code = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
#[Groups(['building:read'])]
|
|
#[SerializedName('couleur')]
|
|
private ?string $color = null;
|
|
|
|
/**
|
|
* @var Collection<int, BuildingCase>
|
|
*/
|
|
#[ORM\OneToMany(targetEntity: BuildingCase::class, mappedBy: 'statut')]
|
|
private Collection $id_case;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->id_case = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function setId(int $id): static
|
|
{
|
|
$this->id = $id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getLabel(): ?string
|
|
{
|
|
return $this->label;
|
|
}
|
|
|
|
public function setLabel(string $label): static
|
|
{
|
|
$this->label = $label;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCode(): ?string
|
|
{
|
|
return $this->code;
|
|
}
|
|
|
|
public function setCode(string $code): static
|
|
{
|
|
$this->code = $code;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getColor(): ?string
|
|
{
|
|
return $this->color;
|
|
}
|
|
|
|
public function setColor(string $color): static
|
|
{
|
|
$this->color = $color;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, BuildingCase>
|
|
*/
|
|
public function getIdCase(): Collection
|
|
{
|
|
return $this->id_case;
|
|
}
|
|
|
|
public function addIdCase(BuildingCase $idCase): static
|
|
{
|
|
if (!$this->id_case->contains($idCase)) {
|
|
$this->id_case->add($idCase);
|
|
$idCase->setStatut($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeIdCase(BuildingCase $idCase): static
|
|
{
|
|
if ($this->id_case->removeElement($idCase)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($idCase->getStatut() === $this) {
|
|
$idCase->setStatut(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|