src/CoreBundle/Entity/PeerSession.php line 15

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JsonSerializable;
  8. /**
  9. * @ORM\Table("peer_session")
  10. * @ORM\Entity(repositoryClass="CoreBundle\Entity\PeerSessionRepository")
  11. */
  12. class PeerSession implements JsonSerializable
  13. {
  14. /**
  15. * @ORM\Column(type="integer")
  16. * @ORM\Id
  17. * @ORM\GeneratedValue(strategy="AUTO")
  18. */
  19. private int $id;
  20. /**
  21. * @ORM\Column(type="string", nullable=true)
  22. */
  23. protected ?string $name;
  24. /**
  25. * @ORM\Column(type="datetime", nullable=true)
  26. */
  27. private ?DateTime $startTime;
  28. /**
  29. * @ORM\Column(type="integer")
  30. */
  31. private int $durationStage1;
  32. /**
  33. * @ORM\Column(type="integer")
  34. */
  35. private int $durationStage2;
  36. /**
  37. * @ORM\Column(type="integer")
  38. */
  39. private int $durationStage3;
  40. /**
  41. * @ORM\ManyToOne(targetEntity="Classroom", inversedBy="peerSessions")
  42. * @ORM\JoinColumn(name="classroom", referencedColumnName="id", onDelete="CASCADE")
  43. */
  44. private Classroom $classroom;
  45. /**
  46. * @ORM\ManyToOne(targetEntity="PeerTheme", inversedBy="peerSessions")
  47. * @ORM\JoinColumn(name="peer_theme_id", referencedColumnName="id")
  48. */
  49. private PeerTheme $peerTheme;
  50. /**
  51. * @var Collection|ArrayCollection|PeerGroup[]
  52. *
  53. * @ORM\OneToMany(targetEntity="CoreBundle\Entity\PeerGroup", mappedBy="peerSession", cascade={"persist", "remove"})
  54. */
  55. private Collection $peerGroups;
  56. /**
  57. * @ORM\Column(type="integer", nullable=false, options={"default"=1})
  58. */
  59. private int $isEnabled = 1;
  60. /**
  61. * @ORM\ManyToOne(targetEntity="PeerThemeClassType")
  62. * @ORM\JoinColumn(name="peer_theme_class_type_id", referencedColumnName="id")
  63. */
  64. private PeerThemeClassType $peerThemeClassType;
  65. public function __construct()
  66. {
  67. $this->peerGroups = new ArrayCollection();
  68. }
  69. /**
  70. * @return string
  71. */
  72. public function getName():string
  73. {
  74. return $this->name;
  75. }
  76. /**
  77. * @param string $name
  78. */
  79. public function setName(string $name): void
  80. {
  81. $this->name = $name;
  82. }
  83. public function getId(): int
  84. {
  85. return $this->id;
  86. }
  87. public function getStartTime(): ?DateTime
  88. {
  89. return $this->startTime;
  90. }
  91. public function setStartTime(DateTime $startTime)
  92. {
  93. $this->startTime = $startTime;
  94. }
  95. public function getDurationStage1(): int
  96. {
  97. return $this->durationStage1;
  98. }
  99. public function setDurationStage1(int $durationStage1)
  100. {
  101. $this->durationStage1 = $durationStage1;
  102. }
  103. public function getDurationStage2(): int
  104. {
  105. return $this->durationStage2;
  106. }
  107. public function setDurationStage2(int $durationStage2)
  108. {
  109. $this->durationStage2 = $durationStage2;
  110. }
  111. public function getDurationStage3(): int
  112. {
  113. return $this->durationStage3;
  114. }
  115. public function setDurationStage3(int $durationStage3)
  116. {
  117. $this->durationStage3 = $durationStage3;
  118. }
  119. public function getClassroom(): Classroom
  120. {
  121. return $this->classroom;
  122. }
  123. public function setClassroom(Classroom $classroom)
  124. {
  125. $this->classroom = $classroom;
  126. }
  127. public function getPeerTheme(): PeerTheme
  128. {
  129. return $this->peerTheme;
  130. }
  131. public function setPeerTheme(PeerTheme $peerTheme)
  132. {
  133. $this->peerTheme = $peerTheme;
  134. }
  135. /**
  136. * @return Collection|ArrayCollection|PeerGroup[]
  137. */
  138. public function getPeerGroups(): Collection
  139. {
  140. return $this->peerGroups;
  141. }
  142. public function addPeerGroup(PeerGroup $peerGroup)
  143. {
  144. $peerGroup->setPeerSession($this);
  145. $this->peerGroups->add($peerGroup);
  146. }
  147. public function getIsEnabled(): int
  148. {
  149. return $this->isEnabled;
  150. }
  151. public function setIsEnabled(int $isEnabled)
  152. {
  153. $this->isEnabled = $isEnabled;
  154. }
  155. public function getPeerThemeClassType(): PeerThemeClassType
  156. {
  157. return $this->peerThemeClassType;
  158. }
  159. public function setPeerThemeClassType(PeerThemeClassType $peerThemeClassType)
  160. {
  161. $this->peerThemeClassType = $peerThemeClassType;
  162. }
  163. public function jsonSerialize(): mixed
  164. {
  165. return [
  166. "id" => $this->getId(),
  167. "startTime" => $this->getStartTime(),
  168. "classroom" => $this->getClassroom(),
  169. "duration" => $this->getDurationStage1(),
  170. ];
  171. }
  172. }