<?php
namespace CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
/**
* @ORM\Table("problem_dnd_bin")
* @ORM\Entity()
*/
class ProblemDndBin implements JsonSerializable, HasMediaInterface
{
use HasMediaTraits;
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private int $id;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $txt;
/**
* TODO: delete when media migration is done
* @ORM\Column(type="text", nullable=true)
*/
private ?string $img;
/**
* TODO: delete when media migration is done
* @ORM\Column(type="text", nullable=true)
*/
private ?string $audio;
/**
* The index of the bin, starting at 1
*
* @ORM\Column(name="binindex", type="smallint")
*/
private int $index;
/**
* @ORM\ManyToOne(targetEntity="ProblemDnd", inversedBy="bins")
* @ORM\JoinColumn(name="problem_dnd_id", referencedColumnName="id")
*/
private ProblemDnd $problemDnd;
public function __construct()
{
$this->imageReference = null;
$this->audioReference = null;
}
public function getId(): int
{
return $this->id;
}
public function getTxt(): ?string
{
return $this->txt;
}
public function setTxt(?string $txt)
{
$this->txt = $txt;
}
public function getImg(): ?string
{
return $this->getImagePath();
}
public function getAudio(): ?string
{
return $this->getAudioPath();
}
public function getProblemDnd(): ProblemDnd
{
return $this->problemDnd;
}
public function setProblemDnd(ProblemDnd $problemDnd)
{
$this->problemDnd = $problemDnd;
}
public function getIndex(): int
{
return $this->index;
}
public function setIndex(int $index)
{
$this->index = $index;
}
public function jsonSerialize(): mixed
{
$txt = ($this->txt !== null && empty(trim($this->txt))) ? null : $this->txt;
return [
"id" => $this->id,
"idx" => $this->index,
"txt" => $txt,
"img" => $this->getImagePath(),
"audio" => $this->getAudioPath(),
];
}
}