src/Entity/SelectionItem.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Entity(repositoryClass="App\Repository\SelectionItemRepository")
  6.  */
  7. class SelectionItem
  8. {
  9.     /**
  10.      * @ORM\Id()
  11.      * @ORM\GeneratedValue()
  12.      * @ORM\Column(type="integer")
  13.      */
  14.     private $id;
  15.     /**
  16.      * @ORM\ManyToOne(targetEntity="App\Entity\Selection", inversedBy="items")
  17.      * @ORM\JoinColumns({
  18.      *   @ORM\JoinColumn(name="selection_id", referencedColumnName="id", onDelete="CASCADE")
  19.      * })
  20.      */
  21.     private $selection;
  22.     /**
  23.      * @ORM\Column(type="string", length=4000, nullable=true, options={"comment":"Intitulé qui apparait dans le formulaire"})
  24.      */
  25.     private $label;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=true, options={"comment":"Tag du champ de recherche"})
  28.      */
  29.     private $tag;
  30.     /**
  31.      * @ORM\Column(type="json", nullable=true, options={"comment":"Parametres de recherche avec infos complementaires pour l ecran de recherche"})
  32.      */
  33.     private $value;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="selectionItems")
  36.      * @ORM\JoinColumns({
  37.      *   @ORM\JoinColumn(name="owner_id", referencedColumnName="id")
  38.      * })
  39.      */
  40.     private $owner;
  41.     /**
  42.      * @ORM\ManyToOne(targetEntity="App\Entity\DnsitEntity", inversedBy="selectionItems")
  43.      * @ORM\JoinColumns({
  44.      *   @ORM\JoinColumn(name="entity_id", referencedColumnName="id")
  45.      * })
  46.      */
  47.     private $entity;
  48.     /**
  49.      * @ORM\Column(type="datetime", nullable=true)
  50.      */
  51.     private $createdAt;
  52.     /**
  53.      * @ORM\Column(type="datetime", nullable=true)
  54.      */
  55.     private $updatedAt;
  56.     /**
  57.      * @ORM\Column(type="integer", nullable=true, options={"default":0, "comment":"code de statut : 0=OK"})
  58.      */
  59.     private $state;
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getLabel(): ?string
  65.     {
  66.         return $this->label;
  67.     }
  68.     public function setLabel(?string $label): self
  69.     {
  70.         $this->label $label;
  71.         return $this;
  72.     }
  73.     public function getTag(): ?string
  74.     {
  75.         return $this->tag;
  76.     }
  77.     public function setTag(?string $tag): self
  78.     {
  79.         $this->tag $tag;
  80.         return $this;
  81.     }
  82.     public function getValue(): ?array
  83.     {
  84.         if(is_string($this->value)) {
  85.             $temp json_decode($this->valuetrue);
  86.             if($temp !== null) {
  87.                 // FIX 19/07/2022 : il arrive que temp soit un JSON encore sous forme de string
  88.                 // pour parer cela, on repasse un coup de json_decode
  89.                 // FIX 22/07/2022 : plusieurs coups...
  90.                 while(gettype($temp) === "string") {
  91.                     $temp json_decode($temptrue);
  92.                 }
  93.                 return $temp;
  94.             }
  95.             else
  96.                 return $this->value;
  97.         }
  98.         else {
  99.             return $this->value;
  100.         }
  101.     }
  102.     public function setValue(?array $value): self
  103.     {
  104.         if(is_string($value)) {
  105.             $temp json_decode($this->valuetrue);
  106.             if($temp !== null)
  107.                 $this->value $temp;
  108.             else
  109.                 $this->value $value;
  110.         }
  111.         else {
  112.             $this->value $value;
  113.         }
  114.         return $this;
  115.     }
  116.     public function getCreatedAt(): ?\DateTimeInterface
  117.     {
  118.         return $this->createdAt;
  119.     }
  120.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  121.     {
  122.         $this->createdAt $createdAt;
  123.         return $this;
  124.     }
  125.     public function getUpdatedAt(): ?\DateTimeInterface
  126.     {
  127.         return $this->updatedAt;
  128.     }
  129.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  130.     {
  131.         $this->updatedAt $updatedAt;
  132.         return $this;
  133.     }
  134.     public function getState(): ?int
  135.     {
  136.         return $this->state;
  137.     }
  138.     public function setState(?int $state): self
  139.     {
  140.         $this->state $state;
  141.         return $this;
  142.     }
  143.     public function getSelection(): ?Selection
  144.     {
  145.         return $this->selection;
  146.     }
  147.     public function setSelection(?Selection $selection): self
  148.     {
  149.         $this->selection $selection;
  150.         return $this;
  151.     }
  152.     public function getOwner(): ?User
  153.     {
  154.         return $this->owner;
  155.     }
  156.     public function setOwner(?User $owner): self
  157.     {
  158.         $this->owner $owner;
  159.         return $this;
  160.     }
  161.     public function getEntity(): ?DnsitEntity
  162.     {
  163.         return $this->entity;
  164.     }
  165.     public function setEntity(?DnsitEntity $entity): self
  166.     {
  167.         $this->entity $entity;
  168.         return $this;
  169.     }
  170. }