src/CoreBundle/Entity/ProblemDndBin.php line 13

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use JsonSerializable;
  5. /**
  6. * @ORM\Table("problem_dnd_bin")
  7. * @ORM\Entity()
  8. */
  9. class ProblemDndBin implements JsonSerializable, HasMediaInterface
  10. {
  11. use HasMediaTraits;
  12. /**
  13. * @ORM\Column(name="id", type="integer")
  14. * @ORM\Id
  15. * @ORM\GeneratedValue(strategy="AUTO")
  16. */
  17. private int $id;
  18. /**
  19. * @ORM\Column(type="text", nullable=true)
  20. */
  21. private ?string $txt;
  22. /**
  23. * TODO: delete when media migration is done
  24. * @ORM\Column(type="text", nullable=true)
  25. */
  26. private ?string $img;
  27. /**
  28. * TODO: delete when media migration is done
  29. * @ORM\Column(type="text", nullable=true)
  30. */
  31. private ?string $audio;
  32. /**
  33. * The index of the bin, starting at 1
  34. *
  35. * @ORM\Column(name="binindex", type="smallint")
  36. */
  37. private int $index;
  38. /**
  39. * @ORM\ManyToOne(targetEntity="ProblemDnd", inversedBy="bins")
  40. * @ORM\JoinColumn(name="problem_dnd_id", referencedColumnName="id")
  41. */
  42. private ProblemDnd $problemDnd;
  43. public function __construct()
  44. {
  45. $this->imageReference = null;
  46. $this->audioReference = null;
  47. }
  48. public function getId(): int
  49. {
  50. return $this->id;
  51. }
  52. public function getTxt(): ?string
  53. {
  54. return $this->txt;
  55. }
  56. public function setTxt(?string $txt)
  57. {
  58. $this->txt = $txt;
  59. }
  60. public function getImg(): ?string
  61. {
  62. return $this->getImagePath();
  63. }
  64. public function getAudio(): ?string
  65. {
  66. return $this->getAudioPath();
  67. }
  68. public function getProblemDnd(): ProblemDnd
  69. {
  70. return $this->problemDnd;
  71. }
  72. public function setProblemDnd(ProblemDnd $problemDnd)
  73. {
  74. $this->problemDnd = $problemDnd;
  75. }
  76. public function getIndex(): int
  77. {
  78. return $this->index;
  79. }
  80. public function setIndex(int $index)
  81. {
  82. $this->index = $index;
  83. }
  84. public function jsonSerialize(): mixed
  85. {
  86. $txt = ($this->txt !== null && empty(trim($this->txt))) ? null : $this->txt;
  87. return [
  88. "id" => $this->id,
  89. "idx" => $this->index,
  90. "txt" => $txt,
  91. "img" => $this->getImagePath(),
  92. "audio" => $this->getAudioPath(),
  93. ];
  94. }
  95. }