src/AdminBundle/Entity/Questionnaire.php line 176

Open in your IDE?
  1. <?php
  2. namespace AdminBundle\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * Questionnaire
  8. */
  9. #[ORM\Table(name: 'questionnaires')]
  10. #[ORM\Entity(repositoryClass: \AdminBundle\Repository\QuestionnaireRepository::class)]
  11. class Questionnaire
  12. {
  13. const TYPE_FIRST_LOGIN = 1;
  14. const TYPE_MONTHLY = 2;
  15. const TYPES = [
  16. self::TYPE_FIRST_LOGIN => 'On First Login',
  17. self::TYPE_MONTHLY => 'Monthly',
  18. ];
  19. /**
  20. * @var int
  21. */
  22. #[ORM\Column(name: 'id', type: 'integer')]
  23. #[ORM\Id]
  24. #[ORM\GeneratedValue(strategy: 'AUTO')]
  25. private $id;
  26. /**
  27. * @var string
  28. */
  29. #[ORM\Column(name: 'type', type: 'integer')]
  30. private $type;
  31. /**
  32. * @var string
  33. */
  34. #[ORM\Column(name: 'title', type: 'string', length: 255)]
  35. private $title;
  36. /**
  37. * @var string
  38. */
  39. #[ORM\Column(name: 'description', type: 'text')]
  40. private $description;
  41. /**
  42. * @var DateTime
  43. */
  44. #[ORM\Column(name: 'released_at', type: 'datetime', nullable: true)]
  45. private $releasedAt;
  46. /**
  47. * @var DateTime
  48. */
  49. #[ORM\Column(name: 'created_at', type: 'datetime')]
  50. private $createdAt;
  51. #[ORM\OneToMany(targetEntity: \AdminBundle\Entity\Question::class, mappedBy: 'questionnaire', cascade: ['persist', 'remove'], orphanRemoval: true)]
  52. private $questions;
  53. public function __construct()
  54. {
  55. $this->createdAt = new DateTime();
  56. $this->questions = new ArrayCollection();
  57. }
  58. public function __toString() {
  59. return $this->title. '';
  60. }
  61. /**
  62. * @return int
  63. */
  64. public function getId()
  65. {
  66. return $this->id;
  67. }
  68. /**
  69. * @return string
  70. */
  71. public function getTitle()
  72. {
  73. return $this->title;
  74. }
  75. /**
  76. * @param string $title
  77. *
  78. * @return Questionaire
  79. */
  80. public function setTitle($title)
  81. {
  82. $this->title = $title;
  83. return $this;
  84. }
  85. /**
  86. * @return int
  87. */
  88. public function getType()
  89. {
  90. return $this->type;
  91. }
  92. /**
  93. * @param int $type
  94. *
  95. * @return Questionaire
  96. */
  97. public function setType($type)
  98. {
  99. $this->type = $type;
  100. return $this;
  101. }
  102. /**
  103. * @return string
  104. */
  105. public function getDescription()
  106. {
  107. return $this->description;
  108. }
  109. /**
  110. * @param string $description
  111. *
  112. * @return Questionaire
  113. */
  114. public function setDescription($description)
  115. {
  116. $this->description = $description;
  117. return $this;
  118. }
  119. /**
  120. * @return DateTime
  121. */
  122. public function getCreatedAt()
  123. {
  124. return $this->createdAt;
  125. }
  126. /**
  127. * @param DateTime $createdAt
  128. *
  129. * @return Questionaire
  130. */
  131. public function setCreatedAt(DateTime $createdAt)
  132. {
  133. $this->createdAt = $createdAt;
  134. return $this;
  135. }
  136. /**
  137. * @return DateTime
  138. */
  139. public function getReleasedAt()
  140. {
  141. return $this->releasedAt;
  142. }
  143. /**
  144. * @param DateTime $releasedAt
  145. *
  146. * @return Questionaire
  147. */
  148. public function setReleasedAt(DateTime $releasedAt = null)
  149. {
  150. $this->releasedAt = $releasedAt;
  151. return $this;
  152. }
  153. /**
  154. * @param Question $question
  155. *
  156. * @return Questionaire
  157. */
  158. public function addQuestion(Question $question)
  159. {
  160. $question->setQuestionnaire($this);
  161. $this->questions->add($question);
  162. return $this;
  163. }
  164. /**
  165. * @param Question $question
  166. *
  167. * @return Questionaire
  168. */
  169. public function removeQuestion(Question $question)
  170. {
  171. if (!$this->questions->contains($question)) {
  172. return;
  173. }
  174. $this->questions->removeElement($question);
  175. $question->setQuestionnaire(null);
  176. return $this;
  177. }
  178. /**
  179. * @return ArrayCollection
  180. */
  181. public function getQuestions()
  182. {
  183. return $this->questions;
  184. }
  185. }