<?php// src/Entity/DynData.phpnamespace App\Entity;use App\Repository\DynDataRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use InvalidArgumentException;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: DynDataRepository::class)]class DynData{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private $id; #[Assert\NotBlank] #[ORM\Column(type: 'text')] private $name; #[ORM\Column(type: 'text', nullable: true)] private $data; #[Assert\Choice(choices: ["TEXT", "ARRAY"])] #[ORM\Column(type: 'string', length: 10)] private $type; #[ORM\OneToMany(targetEntity: DynDataCollection::class, mappedBy: 'DynData', orphanRemoval: 'true', cascade: ["persist"])] private $dataItems; public function __construct() { $this->dataItems = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getType(): ?string { return $this->type; } public function setType(string $type): self { $this->type = $type; return $this; } public function getData() { return json_decode($this->data, true); } public function setData($data): self { $this->data = json_encode($data); return $this; } /** * @return Collection|DynDataCollection[] */ public function getDataItems(): Collection { return $this->dataItems; } public function addDataItem(DynDataCollection $dataItem): self { if (!$this->dataItems->contains($dataItem)) { $this->dataItems[] = $dataItem; $dataItem->setDynData($this); } return $this; } public function removeDataItem(DynDataCollection $dataItem): self { if ($this->dataItems->contains($dataItem)) { $this->dataItems->removeElement($dataItem); // set the owning side to null (unless already changed) if ($dataItem->getDynData() === $this) { $dataItem->setDynData(null); } } return $this; } public function isNew(): bool { return null === $this->id; }}