No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

104 líneas
2.0KB

  1. <?php
  2. namespace App\Entity\Site;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
  7. use App\Entity\File\File;
  8. use Lc\SovBundle\Repository\Site\PageRepository;
  9. /**
  10. * @ORM\Entity(repositoryClass=PageRepository::class)
  11. */
  12. class Page extends AbstractFullEntity
  13. {
  14. /**
  15. * @ORM\Id
  16. * @ORM\GeneratedValue
  17. * @ORM\Column(type="integer")
  18. */
  19. private $id;
  20. /**
  21. * @ORM\ManyToOne(targetEntity=File::class, cascade={"persist", "remove"})
  22. */
  23. private $image;
  24. /**
  25. * @ORM\ManyToMany(targetEntity=File::class, cascade={"persist", "remove"}, orphanRemoval=true)
  26. * @ORM\OrderBy({"position" = "ASC"})
  27. */
  28. private $gallery;
  29. /**
  30. * @ORM\ManyToOne(targetEntity=File::class, cascade={"persist"})
  31. */
  32. private $file;
  33. public function __construct()
  34. {
  35. $this->gallery = new ArrayCollection();
  36. }
  37. public function __toString()
  38. {
  39. return $this->title;
  40. }
  41. public function getId(): ?int
  42. {
  43. return $this->id;
  44. }
  45. public function getImage(): ?File
  46. {
  47. return $this->image;
  48. }
  49. public function setImage(?File $image): self
  50. {
  51. $this->image = $image;
  52. return $this;
  53. }
  54. /**
  55. * @return Collection|File[]
  56. */
  57. public function getGallery(): Collection
  58. {
  59. return $this->gallery;
  60. }
  61. public function addGallery(File $gallery): self
  62. {
  63. if (!$this->gallery->contains($gallery)) {
  64. $this->gallery[] = $gallery;
  65. }
  66. return $this;
  67. }
  68. public function removeGallery(File $gallery): self
  69. {
  70. $this->gallery->removeElement($gallery);
  71. return $this;
  72. }
  73. public function getFile(): ?File
  74. {
  75. return $this->file;
  76. }
  77. public function setFile(?File $file): self
  78. {
  79. $this->file = $file;
  80. return $this;
  81. }
  82. }