src/Entity/Core/ProblemDndBin.php line 11

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