Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

91 line
2.1KB

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