src/Entity/PaletteCouleur.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClass\App\Repository\PaletteCouleurRepository::class)]
  7. class PaletteCouleur implements \Stringable
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column(type'integer')]
  12.     private int $id;
  13.     #[ORM\Column(type'string'length255nullabletrue)]
  14.     private ?string $designationnull;
  15.     #[ORM\Column(type'string'length255nullabletrue)]
  16.     private ?string $code_hexanull;
  17.     #[ORM\OneToMany(targetEntity\App\Entity\Post::class, mappedBy'palettecouleur')]
  18.     private mixed $posts;
  19.     public function __construct()
  20.     {
  21.         $this->posts = new ArrayCollection();
  22.     }
  23.     public function getId(): ?int
  24.     {
  25.         return $this->id;
  26.     }
  27.     public function getDesignation(): ?string
  28.     {
  29.         return $this->designation;
  30.     }
  31.     public function setDesignation(?string $designation): self
  32.     {
  33.         $this->designation $designation;
  34.         return $this;
  35.     }
  36.     public function getCodeHexa(): ?string
  37.     {
  38.         return $this->code_hexa;
  39.     }
  40.     public function setCodeHexa(?string $code_hexa): self
  41.     {
  42.         $this->code_hexa $code_hexa;
  43.         return $this;
  44.     }
  45.     /**
  46.      * @return Collection|Post[]
  47.      */
  48.     public function getPosts(): Collection
  49.     {
  50.         return $this->posts;
  51.     }
  52.     public function addPost(Post $post): self
  53.     {
  54.         if (!$this->posts->contains($post)) {
  55.             $this->posts[] = $post;
  56.             $post->setPalettecouleur($this);
  57.         }
  58.         return $this;
  59.     }
  60.     public function removePost(Post $post): self
  61.     {
  62.         if ($this->posts->contains($post)) {
  63.             $this->posts->removeElement($post);
  64.             // set the owning side to null (unless already changed)
  65.             if ($post->getPalettecouleur() === $this) {
  66.                 $post->setPalettecouleur(null);
  67.             }
  68.         }
  69.         return $this;
  70.     }
  71.     public function __toString(): string
  72.     {
  73.         return (string) $this->designation;
  74.     }
  75. }