Medal.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. namespace AppBundle\Entity\Person;
  3. use AppBundle\Annotation\ExportSplitFields;
  4. use AppBundle\Entity\AccessAndFunction\Access;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Dunglas\ApiBundle\Annotation\Iri;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use AppBundle\Entity\Traits\TimestampableEntity;
  10. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  11. //TODO: fichier à déplacer
  12. /**
  13. * Médaille attribuée à un Access
  14. *
  15. * @Iri("http://schema.org/Medal")
  16. */
  17. #[ORM\Entity]
  18. class Medal
  19. {
  20. use TimestampableEntity;
  21. use CreatorUpdaterEntity;
  22. /**
  23. * @var int
  24. */
  25. #[ORM\Column(type: 'integer')]
  26. #[ORM\Id]
  27. #[ORM\GeneratedValue(strategy: 'AUTO')]
  28. #[Groups(['medal', 'medal_list', 'access_details', 'accesses_list', 'student_list', 'guardians_list', 'teachers_list', 'adherent_list', 'personnels_list', 'ca_list', 'othercontact_list', 'board_list'])]
  29. private $id;
  30. /**
  31. * @var Access
  32. */
  33. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'medals')]
  34. #[ORM\JoinColumn(nullable: false)]
  35. #[Assert\NotNull]
  36. #[Groups(['medal', 'medal_list'])]
  37. private $access;
  38. /**
  39. * @var \DateTime
  40. */
  41. #[ORM\Column(type: 'date', nullable: true)]
  42. #[Assert\Date]
  43. #[Groups(['medal', 'medal_list', 'access_details_medalsfiltered', 'accesses_list_medals', 'student_list_medals', 'guardians_list_medals', 'teachers_list_medals', 'adherent_list_medals', 'personnels_list_medals', 'ca_list_medals', 'othercontact_list_medals', 'board_list_medals'])]
  44. private $medalDate;
  45. /**
  46. * @var string
  47. */
  48. #[ORM\Column(type: 'string')]
  49. #[Assert\Type(type: 'string')]
  50. #[Assert\NotNull]
  51. #[Assert\Choice(callback: ['\AppBundle\Enum\Person\MedalTypeEnum', 'toArray'])]
  52. #[Groups(['medal', 'medal_list', 'access_details_medalsfiltered', 'accesses_list_medals', 'student_list_medals', 'guardians_list_medals', 'teachers_list_medals', 'adherent_list_medals', 'personnels_list_medals', 'ca_list_medals', 'othercontact_list_medals', 'board_list_medals'])]
  53. private $medalType;
  54. /**
  55. * @var string
  56. */
  57. #[ORM\Column(type: 'string', length: 200, nullable: true)]
  58. #[Assert\Type(type: 'string')]
  59. #[Groups(['medal', 'medal_list', 'access_details_medalsfiltered', 'accesses_list_medals', 'student_list_medals', 'guardians_list_medals', 'teachers_list_medals', 'adherent_list_medals', 'personnels_list_medals', 'ca_list_medals', 'othercontact_list_medals', 'board_list_medals'])]
  60. private $otherMedalType;
  61. /**
  62. * @var string
  63. * @ExportSplitFields({"medalDate","medalType","otherMedalType"})
  64. */
  65. #[Groups(['template', 'student_list_medals', 'guardians_list_medals', 'personnels_list_medals', 'othercontact_list_medals', 'ca_list_medals', 'adherent_list_medals', 'accesses_list_medals', 'teachers_list_medals', 'board_list_medals'])]
  66. private $fullLabelTemplate;
  67. /**
  68. * Sets id.
  69. *
  70. * @param int $id
  71. *
  72. * @return $this
  73. */
  74. public function setId($id)
  75. {
  76. $this->id = $id;
  77. return $this;
  78. }
  79. /**
  80. * Gets id.
  81. *
  82. * @return int
  83. */
  84. public function getId()
  85. {
  86. return $this->id;
  87. }
  88. /**
  89. * Sets access.
  90. *
  91. * @param Access $access
  92. *
  93. * @return $this
  94. */
  95. public function setAccess(Access $access)
  96. {
  97. $this->access = $access;
  98. return $this;
  99. }
  100. /**
  101. * Gets access.
  102. *
  103. * @return Access
  104. */
  105. public function getAccess()
  106. {
  107. return $this->access;
  108. }
  109. /**
  110. * Sets medalDate.
  111. *
  112. * @param \DateTime $medalDate
  113. *
  114. * @return $this
  115. */
  116. public function setMedalDate(\DateTime $medalDate = null)
  117. {
  118. $this->medalDate = $medalDate;
  119. return $this;
  120. }
  121. /**
  122. * Gets medalDate.
  123. *
  124. * @return \DateTime
  125. */
  126. public function getMedalDate()
  127. {
  128. return $this->medalDate ? $this->medalDate->format('Y-m-d') : $this->medalDate;
  129. }
  130. /**
  131. * Sets medalType.
  132. *
  133. * @param string $medalType
  134. *
  135. * @return $this
  136. */
  137. public function setMedalType($medalType)
  138. {
  139. $this->medalType = $medalType;
  140. return $this;
  141. }
  142. /**
  143. * Gets medalType.
  144. *
  145. * @return string
  146. */
  147. public function getMedalType()
  148. {
  149. return $this->medalType;
  150. }
  151. /**
  152. * Sets otherMedalType.
  153. *
  154. * @param string $otherMedalType
  155. *
  156. * @return $this
  157. */
  158. public function setOtherMedalType($otherMedalType)
  159. {
  160. $this->otherMedalType = $otherMedalType;
  161. return $this;
  162. }
  163. /**
  164. * Gets otherMedalType.
  165. *
  166. * @return string
  167. */
  168. public function getOtherMedalType()
  169. {
  170. return $this->otherMedalType;
  171. }
  172. /**
  173. * Gets full label.
  174. *
  175. * @return array
  176. */
  177. public function getFullLabelTemplate()
  178. {
  179. return [
  180. $this->getMedalDate(),
  181. ['value' => $this->getMedalType(), 'translate' => true],
  182. $this->getOtherMedalType()
  183. ];
  184. }
  185. }