Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Entity;
  4.  
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8.  
  9. /**
  10. * @ORM\Entity(repositoryClass="App\Repository\ForumTopicsRepository")
  11. */
  12. class ForumTopics
  13. {
  14. /**
  15. * @ORM\Id()
  16. * @ORM\GeneratedValue()
  17. * @ORM\Column(type="integer")
  18. */
  19. private $id;
  20.  
  21. /**
  22. * @ORM\Column(type="string", length=255)
  23. */
  24. private $title;
  25.  
  26. /**
  27. * @ORM\ManyToOne(targetEntity="App\Entity\forumForum", inversedBy="forumTopics")
  28. * @ORM\JoinColumn(nullable=false)
  29. */
  30. private $forum;
  31.  
  32. /**
  33. * @ORM\OneToMany(targetEntity="App\Entity\ForumPosts", mappedBy="topic")
  34. */
  35. private $forumPosts;
  36.  
  37. public function __construct()
  38. {
  39. $this->forumPosts = new ArrayCollection();
  40. }
  41.  
  42. public function getId()
  43. {
  44. return $this->id;
  45. }
  46.  
  47. public function getTitle(): ?string
  48. {
  49. return $this->title;
  50. }
  51.  
  52. public function setTitle(string $title): self
  53. {
  54. $this->title = $title;
  55.  
  56. return $this;
  57. }
  58.  
  59. public function getForum(): ?forumForum
  60. {
  61. return $this->forum;
  62. }
  63.  
  64. public function setForum(?forumForum $forum): self
  65. {
  66. $this->forum = $forum;
  67.  
  68. return $this;
  69. }
  70.  
  71. /**
  72. * @return Collection|ForumPosts[]
  73. */
  74. public function getForumPosts(): Collection
  75. {
  76. return $this->forumPosts;
  77. }
  78.  
  79. public function addForumPost(ForumPosts $forumPost): self
  80. {
  81. if (!$this->forumPosts->contains($forumPost)) {
  82. $this->forumPosts[] = $forumPost;
  83. $forumPost->setTopic($this);
  84. }
  85.  
  86. return $this;
  87. }
  88.  
  89. public function removeForumPost(ForumPosts $forumPost): self
  90. {
  91. if ($this->forumPosts->contains($forumPost)) {
  92. $this->forumPosts->removeElement($forumPost);
  93. // set the owning side to null (unless already changed)
  94. if ($forumPost->getTopic() === $this) {
  95. $forumPost->setTopic(null);
  96. }
  97. }
  98.  
  99. return $this;
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement