src/Entity/Realisation.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\RealisationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Ignore;
  8. /**
  9. * @ORM\Entity(repositoryClass=RealisationRepository::class)
  10. */
  11. class Realisation
  12. {
  13. /**
  14. * @ORM\Id
  15. * @ORM\GeneratedValue
  16. * @ORM\Column(type="integer")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\Column(type="string", length=255)
  21. */
  22. private $titre;
  23. /**
  24. * @ORM\Column(type="string", length=255)
  25. */
  26. private $adresse;
  27. /**
  28. * @ORM\Column(type="string", length=255,nullable=true)
  29. */
  30. private $image;
  31. /**
  32. * @ORM\Column(type="string", length=10000)
  33. */
  34. private $contenu;
  35. /**
  36. * @ORM\ManyToOne(targetEntity=CategorieRealisation::class, inversedBy="realisations")
  37. * @Ignore()
  38. * @ORM\JoinColumn(nullable=false)
  39. */
  40. private $type;
  41. /**
  42. * @ORM\OneToMany(targetEntity=Image::class, mappedBy="realisation", orphanRemoval=true, cascade={"persist"})
  43. */
  44. private $images;
  45. /**
  46. * @ORM\Column(type="string", length=255, nullable="true")
  47. */
  48. private $altDesc;
  49. public function __construct()
  50. {
  51. $this->images = new ArrayCollection();
  52. }
  53. public function getId(): ?int
  54. {
  55. return $this->id;
  56. }
  57. public function getTitre(): ?string
  58. {
  59. return $this->titre;
  60. }
  61. public function setTitre(string $titre): self
  62. {
  63. $this->titre = $titre;
  64. return $this;
  65. }
  66. public function getAdresse(): ?string
  67. {
  68. return $this->adresse;
  69. }
  70. public function setAdresse(string $adresse): self
  71. {
  72. $this->adresse = $adresse;
  73. return $this;
  74. }
  75. public function getImage(): ?string
  76. {
  77. return $this->image;
  78. }
  79. public function setImage(?string $image): self
  80. {
  81. $this->image = $image;
  82. return $this;
  83. }
  84. public function getContenu(): ?string
  85. {
  86. return $this->contenu;
  87. }
  88. public function setContenu(string $contenu): self
  89. {
  90. $this->contenu = $contenu;
  91. return $this;
  92. }
  93. public function getType(): ?CategorieRealisation
  94. {
  95. return $this->type;
  96. }
  97. public function setType(?CategorieRealisation $type): self
  98. {
  99. $this->type = $type;
  100. return $this;
  101. }
  102. /**
  103. * @return Collection|Image[]
  104. */
  105. public function getImages(): Collection
  106. {
  107. return $this->images;
  108. }
  109. public function addImage(Image $image): self
  110. {
  111. if (!$this->images->contains($image)) {
  112. $this->images[] = $image;
  113. $image->setRealisation($this);
  114. }
  115. return $this;
  116. }
  117. public function removeImage(Image $image): self
  118. {
  119. if ($this->images->removeElement($image)) {
  120. // set the owning side to null (unless already changed)
  121. if ($image->getRealisation() === $this) {
  122. $image->setRealisation(null);
  123. }
  124. }
  125. return $this;
  126. }
  127. public function getAltDesc(): ?string
  128. {
  129. return $this->altDesc;
  130. }
  131. public function setAltDesc(?string $altDesc): self
  132. {
  133. $this->altDesc = $altDesc;
  134. return $this;
  135. }
  136. public function getAbsoluteImage() : ?string
  137. {
  138. if(!empty($this->image)){
  139. return sprintf("https://%s/images/upload/%s",$_SERVER['HTTP_HOST'],$this->image);
  140. }
  141. return null;
  142. }
  143. public function getCategorie() : ?int
  144. {
  145. return $this->type?->getId();
  146. }
  147. }