src/CoreBundle/Entity/Appendix.php line 15

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JsonSerializable;
  7. /**
  8. * @ORM\Table(name="appendix")
  9. * @ORM\Entity
  10. */
  11. class Appendix implements JsonSerializable
  12. {
  13. /**
  14. * @var int
  15. *
  16. * @ORM\Column(name="id", type="integer")
  17. * @ORM\Id
  18. * @ORM\GeneratedValue(strategy="AUTO")
  19. */
  20. private $id;
  21. /**
  22. * @var string
  23. *
  24. * @ORM\Column(name="file_name", type="string", length=255, unique=true)
  25. */
  26. private $fileName;
  27. /**
  28. * @var ArrayCollection
  29. *
  30. * @ORM\ManyToMany(targetEntity="Mathproblem", mappedBy="appendices")
  31. */
  32. private $problems;
  33. public function __construct()
  34. {
  35. $this->problems = new ArrayCollection();
  36. }
  37. public function getId(): int
  38. {
  39. return $this->id;
  40. }
  41. public function setFileName(string $fileName)
  42. {
  43. $this->fileName = $fileName;
  44. }
  45. public function getFileName(): string
  46. {
  47. return $this->fileName;
  48. }
  49. public function getProblems(): Collection
  50. {
  51. return $this->problems;
  52. }
  53. public function setProblems(ArrayCollection $problems): void
  54. {
  55. $this->problems = $problems;
  56. }
  57. public function jsonSerialize(): array
  58. {
  59. return [
  60. 'id' => $this->id,
  61. 'fileName' => '/appendices/' . $this->fileName
  62. ];
  63. }
  64. }