src/CoreBundle/Entity/DictateSession.php line 16

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use JsonSerializable;
  6. use UserBundle\Entity\User;
  7. /**
  8. * @ORM\Table("dictate_session")
  9. * @ORM\Entity(repositoryClass="CoreBundle\Entity\DictateSessionRepository")
  10. */
  11. class DictateSession implements JsonSerializable
  12. {
  13. /**
  14. * @var int
  15. *
  16. * @ORM\Column(name="id", type="integer")
  17. * @ORM\Id
  18. * @ORM\GeneratedValue(strategy="AUTO")
  19. */
  20. private $id;
  21. /**
  22. * @var Dictate
  23. *
  24. * @ORM\ManyToOne(targetEntity="CoreBundle\Entity\Dictate")
  25. * @ORM\JoinColumn(name="dictate", referencedColumnName="id")
  26. */
  27. private $dictate;
  28. /**
  29. * @var User
  30. *
  31. * @ORM\ManyToOne(targetEntity="UserBundle\Entity\User")
  32. * @ORM\JoinColumn(name="created_by", referencedColumnName="id")
  33. */
  34. private $createdBy;
  35. /**
  36. * @var Classroom
  37. *
  38. * @ORM\ManyToOne(targetEntity="CoreBundle\Entity\Classroom")
  39. */
  40. private $classroom;
  41. /**
  42. * @var string
  43. *
  44. * @ORM\Column(name="name", type="string", length=255, nullable=true)
  45. */
  46. private $name;
  47. /**
  48. * @var \DateTime
  49. *
  50. * @ORM\Column(name="startTime", type="datetime", nullable=true)
  51. */
  52. private $startTime;
  53. /**
  54. * @var \DateTime
  55. * @ORM\Column(name="deadline", type="datetime", nullable=true)
  56. */
  57. private $deadline;
  58. /**
  59. * @var \DateTime
  60. *
  61. * @ORM\Column(name="createdAt", type="datetime", nullable=false)
  62. */
  63. private $createdAt;
  64. /**
  65. * @var DictateUnit[]
  66. *
  67. * @ORM\OneToMany(targetEntity="CoreBundle\Entity\DictateUnit", mappedBy="dictateSession", cascade={"persist"})
  68. */
  69. private $dictateUnits;
  70. /**
  71. * @ORM\Column(type="boolean", nullable=true)
  72. */
  73. private ?bool $deleted;
  74. /**
  75. * @var int
  76. *
  77. * @ORM\Column(type="smallint", nullable=true)
  78. */
  79. private ?int $duration;
  80. /**
  81. * DictateSession constructor.
  82. * @throws \Exception
  83. */
  84. public function __construct()
  85. {
  86. $this->createdAt = new \DateTime('now', new \DateTimeZone('Europe/Copenhagen'));
  87. $this->dictateUnits = new ArrayCollection();
  88. $this->startTime = new \DateTime("now");
  89. $this->deadline = new \DateTime("+1DAY");
  90. }
  91. /**
  92. * @return int
  93. */
  94. public function getId(): int
  95. {
  96. return $this->id;
  97. }
  98. /**
  99. * @param int $id
  100. */
  101. public function setId(int $id): void
  102. {
  103. $this->id = $id;
  104. }
  105. /**
  106. * @return Dictate
  107. */
  108. public function getDictate()
  109. {
  110. return $this->dictate;
  111. }
  112. /**
  113. * @param Dictate $dictate
  114. */
  115. public function setDictate(Dictate $dictate): void
  116. {
  117. $this->dictate = $dictate;
  118. }
  119. /**
  120. * @return User
  121. */
  122. public function getCreatedBy()
  123. {
  124. return $this->createdBy;
  125. }
  126. /**
  127. * @param User $createdBy
  128. */
  129. public function setCreatedBy(User $createdBy): void
  130. {
  131. $this->createdBy = $createdBy;
  132. }
  133. /**
  134. * @return Classroom
  135. */
  136. public function getClassroom()
  137. {
  138. return $this->classroom;
  139. }
  140. /**
  141. * @param Classroom $classroom
  142. */
  143. public function setClassroom(Classroom $classroom): void
  144. {
  145. $this->classroom = $classroom;
  146. }
  147. /**
  148. * @return string
  149. */
  150. public function getName()
  151. {
  152. return $this->name;
  153. }
  154. public function setName(?string $name): void
  155. {
  156. $this->name = $name;
  157. }
  158. /**
  159. * @return \DateTime
  160. */
  161. public function getStartTime()
  162. {
  163. return $this->startTime;
  164. }
  165. /**
  166. * @param \DateTime $startTime
  167. */
  168. public function setStartTime(\DateTime $startTime): void
  169. {
  170. $this->startTime = $startTime;
  171. }
  172. /**
  173. * @return \DateTime
  174. */
  175. public function getDeadline()
  176. {
  177. return $this->deadline;
  178. }
  179. /**
  180. * @param \DateTime $deadline
  181. */
  182. public function setDeadline(\DateTime $deadline): void
  183. {
  184. $this->deadline = $deadline;
  185. }
  186. /**
  187. * @return \DateTime
  188. */
  189. public function getCreatedAt()
  190. {
  191. return $this->createdAt;
  192. }
  193. /**
  194. * @param \DateTime $createdAt
  195. */
  196. public function setCreatedAt(\DateTime $createdAt): void
  197. {
  198. $this->createdAt = $createdAt;
  199. }
  200. /**
  201. * @return DictateUnit[]
  202. */
  203. public function getDictateUnits()
  204. {
  205. return $this->dictateUnits;
  206. }
  207. /**
  208. * @param DictateUnit[] $dictateUnits
  209. */
  210. public function setDictateUnits(array $dictateUnits): void
  211. {
  212. $this->dictateUnits = $dictateUnits;
  213. }
  214. public function isDeleted(): ?bool
  215. {
  216. return $this->deleted;
  217. }
  218. public function setDeleted(bool $deleted): void
  219. {
  220. $this->deleted = $deleted;
  221. }
  222. public function getDuration(): ?int
  223. {
  224. return $this->duration;
  225. }
  226. public function setDuration(?int $duration)
  227. {
  228. $this->duration = $duration;
  229. }
  230. public function jsonSerialize(): array
  231. {
  232. return [
  233. 'id' => $this->getId(),
  234. 'name' => $this->getName(),
  235. 'deadline' => $this->getDeadline(),
  236. 'startTime' => $this->getStartTime(),
  237. 'duration' => $this->getDuration(),
  238. // Add other fields as needed
  239. ];
  240. }
  241. }