*/ #[ORM\Column(type: Types::JSONB)] public array $data = []; #[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: false)] public private(set) \DateTimeImmutable $created; public function __construct( #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] #[ORM\ManyToOne(inversedBy: 'eliminations')] public Quiz $quiz, ) {} /** @param InputBag $inputBag */ public function updateFromInputBag(InputBag $inputBag): self { foreach (array_keys($this->data) as $name) { $newColour = $inputBag->get('colour-'.mb_strtolower($name)); if (\is_string($newColour)) { $this->data[$name] = $inputBag->get('colour-'.mb_strtolower($name)); } } return $this; } public function getScreenColour(?string $name): ?string { return $this->data[$name] ?? null; } #[ORM\PrePersist] public function setCreatedAtValue(): void { $this->created = new DateTimeImmutable(); } }