<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\SelectionItemRepository")
*/
class SelectionItem
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Selection", inversedBy="items")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="selection_id", referencedColumnName="id", onDelete="CASCADE")
* })
*/
private $selection;
/**
* @ORM\Column(type="string", length=4000, nullable=true, options={"comment":"Intitulé qui apparait dans le formulaire"})
*/
private $label;
/**
* @ORM\Column(type="string", length=255, nullable=true, options={"comment":"Tag du champ de recherche"})
*/
private $tag;
/**
* @ORM\Column(type="json", nullable=true, options={"comment":"Parametres de recherche avec infos complementaires pour l ecran de recherche"})
*/
private $value;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="selectionItems")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="owner_id", referencedColumnName="id")
* })
*/
private $owner;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\DnsitEntity", inversedBy="selectionItems")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="entity_id", referencedColumnName="id")
* })
*/
private $entity;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\Column(type="integer", nullable=true, options={"default":0, "comment":"code de statut : 0=OK"})
*/
private $state;
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(?string $label): self
{
$this->label = $label;
return $this;
}
public function getTag(): ?string
{
return $this->tag;
}
public function setTag(?string $tag): self
{
$this->tag = $tag;
return $this;
}
public function getValue(): ?array
{
if(is_string($this->value)) {
$temp = json_decode($this->value, true);
if($temp !== null) {
// FIX 19/07/2022 : il arrive que temp soit un JSON encore sous forme de string
// pour parer cela, on repasse un coup de json_decode
// FIX 22/07/2022 : plusieurs coups...
while(gettype($temp) === "string") {
$temp = json_decode($temp, true);
}
return $temp;
}
else
return $this->value;
}
else {
return $this->value;
}
}
public function setValue(?array $value): self
{
if(is_string($value)) {
$temp = json_decode($this->value, true);
if($temp !== null)
$this->value = $temp;
else
$this->value = $value;
}
else {
$this->value = $value;
}
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getState(): ?int
{
return $this->state;
}
public function setState(?int $state): self
{
$this->state = $state;
return $this;
}
public function getSelection(): ?Selection
{
return $this->selection;
}
public function setSelection(?Selection $selection): self
{
$this->selection = $selection;
return $this;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(?User $owner): self
{
$this->owner = $owner;
return $this;
}
public function getEntity(): ?DnsitEntity
{
return $this->entity;
}
public function setEntity(?DnsitEntity $entity): self
{
$this->entity = $entity;
return $this;
}
}