src/Entity/ValueDeclination.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ValueDeclinationRepository;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use JsonSerializable;
  8. /**
  9.  * @ORM\Entity()
  10.  * @UniqueEntity(fields={"name", "declination"}, message="Cette valeur existe déjà pour cette déclinaison.")
  11.  */
  12. /**
  13.  * @ORM\Entity(repositoryClass=ValueDeclinationRepository::class)
  14.  */
  15. class ValueDeclination implements JsonSerializable
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $name;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity=Declination::class, inversedBy="valueDeclinations")
  29.      */
  30.     private $declination;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      */
  34.     private $code;
  35.     /**
  36.      * @ORM\OneToMany(targetEntity=ValueDeclination::class, mappedBy="parent")
  37.      */
  38.     private $subValueDeclinations;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity=ValueDeclination::class, inversedBy="subValueDeclinations")
  41.      */
  42.     private $parent;
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getName(): ?string
  48.     {
  49.         return $this->name;
  50.     }
  51.     public function setName(string $name): self
  52.     {
  53.         $this->name $name;
  54.         return $this;
  55.     }
  56.     public function getDeclination(): ?Declination
  57.     {
  58.         return $this->declination;
  59.     }
  60.     public function setDeclination(?Declination $declination): self
  61.     {
  62.         $this->declination $declination;
  63.         return $this;
  64.     }
  65.     public function getCode(): ?string
  66.     {
  67.         return $this->code;
  68.     }
  69.     public function setCode(?string $code): self
  70.     {
  71.         $this->code $code;
  72.         return $this;
  73.     }
  74.     /**
  75.      * @return self[]
  76.      */
  77.     public function getParent(): ?self
  78.     {
  79.         return $this->parent;
  80.     }
  81.     public function setParent(?self $parent): ?self
  82.     {
  83.         $this->parent $parent;
  84.         return $this;
  85.     }
  86.     /**
  87.      * @return Collection|self[]
  88.      */
  89.     public function getSubValueDeclinations(): Collection
  90.     {
  91.         return $this->subValueDeclinations;
  92.     }
  93.     public function jsonSerialize()
  94.     {
  95.         return array(
  96.             'id' => $this->getId(),
  97.             'name' => $this->getName(),
  98.             'code' => $this->getCode()
  99.         );
  100.     }
  101. }