src/Entity/TransactionalEmailContent.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TransactionalEmailContentRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. /**
  9. * @ORM\Entity(repositoryClass=TransactionalEmailContentRepository::class)
  10. *
  11. * @UniqueEntity(
  12. * fields={"slug"},
  13. * message="Ce slug existe déjà."
  14. * )
  15. */
  16. class TransactionalEmailContent
  17. {
  18. /**
  19. * @ORM\Id
  20. * @ORM\GeneratedValue
  21. * @ORM\Column(type="integer")
  22. */
  23. private ?int $id = NULL;
  24. /**
  25. * @ORM\Column(type="string", length=255)
  26. */
  27. private ?string $slug = NULL;
  28. /**
  29. * @ORM\Column(type="string", length=255)
  30. */
  31. private ?string $subject = NULL;
  32. /**
  33. * @ORM\Column(type="text")
  34. */
  35. private ?string $content = NULL;
  36. /**
  37. * @ORM\Column(type="boolean")
  38. */
  39. private bool $enabled = TRUE;
  40. /**
  41. * @ORM\Column(type="json", nullable=true)
  42. */
  43. private array $cc = [];
  44. /**
  45. * @ORM\Column(type="boolean", options={"default":true})
  46. */
  47. private bool $centerContent;
  48. /**
  49. * @ORM\OneToMany(targetEntity=TransactionalEmailTranslation::class, mappedBy="transactionalEmailContent", cascade={"persist","remove"})
  50. *
  51. */
  52. private Collection $transactionalEmailTranslations;
  53. /**
  54. * @ORM\OneToMany(
  55. * targetEntity="TransactionalEmailContent",
  56. * mappedBy="parent",
  57. * cascade={"persist"}
  58. * )
  59. */
  60. private Collection $children;
  61. /**
  62. * @ORM\ManyToOne(
  63. * targetEntity="TransactionalEmailContent",
  64. * inversedBy="children"
  65. * )
  66. * @ORM\JoinColumn(
  67. * name="parent_id",
  68. * referencedColumnName="id",
  69. * nullable=true,
  70. * onDelete="SET NULL"
  71. * )
  72. */
  73. private ?self $parent = null;
  74. public function __construct()
  75. {
  76. $this->transactionalEmailTranslations = new ArrayCollection();
  77. $this->children = new ArrayCollection();
  78. }
  79. public function getId(): ?int
  80. {
  81. return $this->id;
  82. }
  83. public function getSlug(): ?string
  84. {
  85. return $this->slug;
  86. }
  87. public function setSlug(string $slug): self
  88. {
  89. $this->slug = $slug;
  90. return $this;
  91. }
  92. public function getSubject(): ?string
  93. {
  94. return $this->subject;
  95. }
  96. public function setSubject(string $subject): self
  97. {
  98. $this->subject = $subject;
  99. return $this;
  100. }
  101. public function getContent(): ?string
  102. {
  103. return $this->content;
  104. }
  105. public function setContent(string $content): self
  106. {
  107. $this->content = $content;
  108. return $this;
  109. }
  110. public function isEnabled(): ?bool
  111. {
  112. return $this->enabled;
  113. }
  114. public function setEnabled(bool $enabled): self
  115. {
  116. $this->enabled = $enabled;
  117. return $this;
  118. }
  119. public function getCc(): ?array
  120. {
  121. return $this->cc;
  122. }
  123. public function setCc(?array $cc): self
  124. {
  125. $this->cc = $cc;
  126. return $this;
  127. }
  128. public function getCenterContent(): bool
  129. {
  130. return $this->centerContent;
  131. }
  132. public function setCenterContent( bool $centerContent ): self
  133. {
  134. $this->centerContent = $centerContent;
  135. return $this;
  136. }
  137. /**
  138. * @return Collection<int, TransactionalEmailTranslation>
  139. */
  140. public function getTransactionalEmailTranslations(): Collection
  141. {
  142. return $this->transactionalEmailTranslations;
  143. }
  144. /**
  145. * @param iterable<TransactionalEmailTranslation> $transactionalEmailTranslations
  146. *
  147. * @return $this
  148. */
  149. public function setTransactionalEmailTranslations(iterable $transactionalEmailTranslations): self
  150. {
  151. foreach($this->transactionalEmailTranslations as $transactionalEmailTranslation)
  152. {
  153. $this->removeTransactionalEmailTranslation($transactionalEmailTranslation);
  154. }
  155. foreach($transactionalEmailTranslations as $transactionalEmailTranslation)
  156. {
  157. $this->addTransactionalEmailTranslation($transactionalEmailTranslation);
  158. }
  159. return $this;
  160. }
  161. public function addTransactionalEmailTranslation(TransactionalEmailTranslation $transactionalEmailTranslation): self
  162. {
  163. if (!$this->transactionalEmailTranslations->contains($transactionalEmailTranslation)) {
  164. $this->transactionalEmailTranslations[] = $transactionalEmailTranslation;
  165. $transactionalEmailTranslation->setTransactionalEmailContent($this);
  166. }
  167. return $this;
  168. }
  169. public function removeTransactionalEmailTranslation(TransactionalEmailTranslation $transactionalEmailTranslation): self
  170. {
  171. if ($this->transactionalEmailTranslations->removeElement($transactionalEmailTranslation)) {
  172. // set the owning side to null (unless already changed)
  173. if ($transactionalEmailTranslation->getTransactionalEmailContent() === $this) {
  174. $transactionalEmailTranslation->setTransactionalEmailContent(NULL);
  175. }
  176. }
  177. return $this;
  178. }
  179. /**
  180. * @return Collection|TransactionalEmailContent[]
  181. */
  182. public function getChildren(): Collection
  183. {
  184. return $this->children;
  185. }
  186. public function addChild(TransactionalEmailContent $child): self
  187. {
  188. if (!$this->children->contains($child)) {
  189. $this->children->add($child);
  190. $child->setParent($this);
  191. }
  192. return $this;
  193. }
  194. public function removeChild(TransactionalEmailContent $child): self
  195. {
  196. if ($this->children->removeElement($child)) {
  197. if ($child->getParent() === $this) {
  198. $child->setParent(null);
  199. }
  200. }
  201. return $this;
  202. }
  203. public function getParent(): ?TransactionalEmailContent
  204. {
  205. return $this->parent;
  206. }
  207. public function setParent(?TransactionalEmailContent $parent): self
  208. {
  209. $this->parent = $parent;
  210. return $this;
  211. }
  212. }