src/Bundles/Messenger/Entity/Article.php line 13

Open in your IDE?
  1. <?php
  2. namespace Bundles\Messenger\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Bundles\Messenger\Repository\ArticleRepository;
  7. /**
  8. * @ORM\Entity(repositoryClass=ArticleRepository::class)
  9. */
  10. class Article {
  11. /**
  12. * @ORM\Id
  13. * @ORM\GeneratedValue
  14. * @ORM\Column(type="integer")
  15. */
  16. private $id;
  17. /**
  18. * @ORM\Column(type="string", length=255)
  19. */
  20. private $title;
  21. /**
  22. * @ORM\Column(type="text", nullable=true)
  23. */
  24. private $description;
  25. /**
  26. * @ORM\Column(type="text", nullable=true)
  27. */
  28. private $content;
  29. /**
  30. * @ORM\Column(type="string", length=20)
  31. */
  32. private $created;
  33. /**
  34. * @ORM\Column(type="boolean")
  35. */
  36. private $status;
  37. /**
  38. * @ORM\Column(type="boolean")
  39. */
  40. private $new = true;
  41. /**
  42. * @ORM\Column(type="string", length=20, nullable=true)
  43. */
  44. private $showFrom;
  45. /**
  46. * @ORM\Column(type="string", length=20, nullable=true)
  47. */
  48. private $showTo;
  49. /**
  50. * @ORM\ManyToMany(targetEntity=ArticleTag::class)
  51. * @ORM\JoinTable(name="article_related_tags")
  52. *
  53. */
  54. private $tags;
  55. public function __construct() {
  56. $this->tags = new ArrayCollection();
  57. $this->setCreated(date('Y-m-d H:i'));
  58. }
  59. public function getId(): ?int {
  60. return $this->id;
  61. }
  62. public function getTitle(): ?string {
  63. return $this->title;
  64. }
  65. public function setTitle(string $title): self {
  66. $this->title = $title;
  67. return $this;
  68. }
  69. public function getDescription(): ?string {
  70. return $this->description;
  71. }
  72. public function setDescription(string $description): self {
  73. $this->description = $description;
  74. return $this;
  75. }
  76. public function getContent(): ?string {
  77. return $this->content;
  78. }
  79. public function setContent(string $content): self {
  80. $this->content = $content;
  81. return $this;
  82. }
  83. public function getCreated(): ?string {
  84. return $this->created;
  85. }
  86. public function setCreated(string $created): self {
  87. $this->created = $created;
  88. return $this;
  89. }
  90. public function isStatus(): ?bool {
  91. return $this->status;
  92. }
  93. public function setStatus(bool $status): self {
  94. $this->status = $status;
  95. return $this;
  96. }
  97. public function getShowFrom(): ?string {
  98. return $this->showFrom;
  99. }
  100. public function setShowFrom(?string $showFrom): self {
  101. $this->showFrom = $showFrom;
  102. return $this;
  103. }
  104. public function getShowTo(): ?string {
  105. return $this->showTo;
  106. }
  107. public function setShowTo(?string $showTo): self {
  108. $this->showTo = $showTo;
  109. return $this;
  110. }
  111. /**
  112. * @return Collection<int, ArticleTag>
  113. */
  114. public function getTags(): Collection {
  115. return $this->tags;
  116. }
  117. public function addTag(ArticleTag $tag): self {
  118. if (!$this->tags->contains($tag)) {
  119. $this->tags[] = $tag;
  120. $tag->setArticle($this);
  121. }
  122. return $this;
  123. }
  124. public function removeTag(ArticleTag $tag): self {
  125. if ($this->tags->removeElement($tag)) {
  126. // set the owning side to null (unless already changed)
  127. if ($tag->getArticle() === $this) {
  128. $tag->setArticle(null);
  129. }
  130. }
  131. return $this;
  132. }
  133. /**
  134. * @return bool
  135. */
  136. public function isNew(): bool {
  137. return $this->new;
  138. }
  139. /**
  140. * @param bool $new
  141. */
  142. public function setNew(bool $new = true): void {
  143. $this->new = $new;
  144. }
  145. }