CQuizCategory.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <?php
  2. namespace Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Gedmo\Mapping\Annotation as Gedmo;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. /**
  7. * CQuizCategory
  8. *
  9. * @Gedmo\Tree(type="nested")
  10. * @ORM\Table(name="c_quiz_category")
  11. * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")
  12. */
  13. class CQuizCategory
  14. {
  15. /**
  16. * @var integer
  17. *
  18. * @ORM\Column(name="iid", type="integer", precision=0, scale=0, nullable=false, unique=false)
  19. * @ORM\Id
  20. * @ORM\GeneratedValue(strategy="IDENTITY")
  21. */
  22. private $iid;
  23. /**
  24. * @var integer
  25. *
  26. * @ORM\Column(name="c_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
  27. */
  28. private $cId;
  29. /**
  30. * @var string
  31. *
  32. * @ORM\Column(name="title", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
  33. */
  34. private $title;
  35. /**
  36. * @var string
  37. *
  38. * @ORM\Column(name="description", type="text", precision=0, scale=0, nullable=false, unique=false)
  39. */
  40. private $description;
  41. /**
  42. *
  43. * @ORM\Column(name="parent_id", type="integer")
  44. */
  45. private $parentId;
  46. /**
  47. * @Gedmo\TreeParent
  48. * @ORM\ManyToOne(targetEntity="CQuizCategory", inversedBy="children")
  49. * @ORM\JoinColumn(name="parent_id", referencedColumnName="iid", onDelete="SET NULL")
  50. */
  51. private $parent;
  52. /**
  53. * @Gedmo\TreeLeft
  54. * @ORM\Column(name="lft", type="integer")
  55. */
  56. private $lft;
  57. /**
  58. * @Gedmo\TreeLevel
  59. * @ORM\Column(name="lvl", type="integer")
  60. */
  61. private $lvl;
  62. /**
  63. * @Gedmo\TreeRight
  64. * @ORM\Column(name="rgt", type="integer")
  65. */
  66. private $rgt;
  67. /**
  68. * @Gedmo\TreeRoot
  69. * @ORM\Column(name="root", type="integer", nullable=true)
  70. */
  71. private $root;
  72. /**
  73. * @ORM\OneToMany(targetEntity="CQuizCategory", mappedBy="parent")
  74. * @ORM\OrderBy({"lft" = "ASC"})
  75. */
  76. private $children;
  77. /**
  78. *
  79. * @ORM\Column(name="visibility", type="integer")
  80. */
  81. private $visibility;
  82. /**
  83. * @ORM\OneToMany(targetEntity="CQuizQuestionRelCategory", mappedBy="category")
  84. **/
  85. private $quizQuestionRelCategoryList;
  86. public function __construct()
  87. {
  88. $this->quizQuestionRelCategoryList = new ArrayCollection();
  89. }
  90. public function setParent(CQuizCategory $parent = null)
  91. {
  92. $this->parent = $parent;
  93. }
  94. public function getParent()
  95. {
  96. return $this->parent;
  97. }
  98. public function getQuestions()
  99. {
  100. $questions = new ArrayCollection();
  101. foreach ($this->quizQuestionRelCategoryList as $relQuestion) {
  102. $questions[] = $relQuestion->getQuestion();
  103. }
  104. return $questions;
  105. }
  106. /**
  107. * Set cId
  108. *
  109. * @param integer $cId
  110. * @return CQuizQuestionCategory
  111. */
  112. public function setCId($cId)
  113. {
  114. $this->cId = $cId;
  115. return $this;
  116. }
  117. /**
  118. * Get cId
  119. *
  120. * @return integer
  121. */
  122. public function getCId()
  123. {
  124. return $this->cId;
  125. }
  126. /**
  127. * Set id
  128. *
  129. * @param integer $id
  130. * @return CQuizQuestionCategory
  131. */
  132. public function setIid($id)
  133. {
  134. $this->iid = $id;
  135. return $this;
  136. }
  137. /**
  138. * Get id
  139. *
  140. * @return integer
  141. */
  142. public function getIid()
  143. {
  144. return $this->iid;
  145. }
  146. /**
  147. * Set title
  148. *
  149. * @param string $title
  150. * @return CQuizQuestionCategory
  151. */
  152. public function setTitle($title)
  153. {
  154. $this->title = $title;
  155. return $this;
  156. }
  157. /**
  158. * Get title
  159. *
  160. * @return string
  161. */
  162. public function getTitle()
  163. {
  164. return $this->title;
  165. }
  166. /**
  167. * Set description
  168. *
  169. * @param string $description
  170. * @return CQuizQuestionCategory
  171. */
  172. public function setDescription($description)
  173. {
  174. $this->description = $description;
  175. return $this;
  176. }
  177. /**
  178. * Get description
  179. *
  180. * @return string
  181. */
  182. public function getDescription()
  183. {
  184. return $this->description;
  185. }
  186. /**
  187. * Set cId
  188. *
  189. * @param integer $cId
  190. * @return CQuizQuestionCategory
  191. */
  192. public function setParentId($id)
  193. {
  194. $this->parentId = $id;
  195. return $this;
  196. }
  197. /**
  198. * Get cId
  199. *
  200. * @return integer
  201. */
  202. public function getParentId()
  203. {
  204. return $this->parentId;
  205. }
  206. /**
  207. * @return integer
  208. */
  209. public function getVisibility()
  210. {
  211. return $this->visibility;
  212. }
  213. /**
  214. * @param $visibility
  215. * @return $this
  216. */
  217. public function setVisibility($visibility)
  218. {
  219. $this->visibility = $visibility;
  220. return $this;
  221. }
  222. }