Donor.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <?php
  2. namespace AppBundle\Entity\Donor;
  3. use AppBundle\Annotation\DefaultField;
  4. use AppBundle\Entity\AccessAndFunction\Access;
  5. use AppBundle\Entity\Organization\Organization;
  6. use AppBundle\Entity\Traits\ActivityPeriodTrait;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Dunglas\ApiBundle\Annotation\Iri;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use AppBundle\Entity\Traits\TimestampableEntity;
  12. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  13. /**
  14. * Don d'un Access à une Organization
  15. *
  16. * @Iri("http://schema.org/Donor")
  17. */
  18. #[ORM\Entity]
  19. class Donor
  20. {
  21. use TimestampableEntity;
  22. use CreatorUpdaterEntity;
  23. use ActivityPeriodTrait;
  24. /**
  25. * @var int
  26. */
  27. #[ORM\Column(type: 'integer')]
  28. #[ORM\Id]
  29. #[ORM\GeneratedValue(strategy: 'AUTO')]
  30. #[Groups(['donor', 'donor_list', 'access_details', 'access_details_organization'])]
  31. private $id;
  32. /**
  33. * @var Access
  34. */
  35. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'donors')]
  36. #[ORM\JoinColumn(nullable: false)]
  37. #[Assert\NotNull]
  38. #[Groups(['donor', 'donor_list', 'access_details_organization'])]
  39. private $access;
  40. /**
  41. * @var string
  42. */
  43. #[ORM\Column(type: 'string', length: 40, nullable: true)]
  44. #[Assert\Type(type: 'string')]
  45. #[Groups(['donor', 'donor_list', 'access_details_donorsfiltered'])]
  46. private $wording;
  47. /**
  48. * @var float
  49. *
  50. *
  51. */
  52. #[ORM\Column(type: 'float', nullable: true)]
  53. #[Assert\Type(type: 'float')]
  54. #[Groups(['donor', 'donor_list', 'access_details_donorsfiltered'])]
  55. private $amount;
  56. /**
  57. * @var \DateTime
  58. */
  59. #[ORM\Column(type: 'date', nullable: true)]
  60. #[Assert\Date]
  61. #[Groups(['donor', 'donor_list'])]
  62. private $paymentDate;
  63. /**
  64. * @var bool
  65. */
  66. #[ORM\Column(type: 'boolean', options: ['default' => false], nullable: true)]
  67. #[Assert\Type(type: 'boolean')]
  68. #[Groups(['donor', 'donor_list'])]
  69. private $emailVisibility;
  70. /**
  71. * @var bool
  72. */
  73. #[ORM\Column(type: 'boolean', options: ['default' => false], nullable: true)]
  74. #[Assert\Type(type: 'boolean')]
  75. #[Groups(['donor', 'donor_list'])]
  76. private $logoVisibility;
  77. /**
  78. * @var bool
  79. */
  80. #[ORM\Column(type: 'boolean', options: ['default' => false], nullable: true)]
  81. #[Assert\Type(type: 'boolean')]
  82. #[Groups(['donor', 'donor_list', 'access_details_organization'])]
  83. private $donorVisibility;
  84. /**
  85. * @var string
  86. */
  87. #[ORM\Column(type: 'simple_array', nullable: true)]
  88. #[Assert\Type(type: 'array')]
  89. #[Assert\Choice(callback: ['\AppBundle\Enum\Donor\DonorDisplayedOnEnum', 'toArray'], multiple: true)]
  90. #[Groups(['donor'])]
  91. private $displayedOn;
  92. /**
  93. * @var Organization
  94. *
  95. * @DefaultField()
  96. */
  97. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization', inversedBy: 'donors')]
  98. #[Groups(['donor'])]
  99. private $organization;
  100. /**
  101. * @var bool
  102. */
  103. #[ORM\Column(type: 'boolean', options: ['default' => false], nullable: true)]
  104. #[Assert\Type(type: 'boolean')]
  105. #[Groups(['donor', 'donor_list', 'access_details_organization'])]
  106. private $federationDisplay;
  107. /**
  108. * @var bool
  109. */
  110. #[ORM\Column(type: 'boolean', options: ['default' => false], nullable: true)]
  111. #[Assert\Type(type: 'boolean')]
  112. #[Groups(['donor', 'donor_list', 'access_details_organization'])]
  113. private $associationDisplay;
  114. /**
  115. * Sets id.
  116. *
  117. * @param int $id
  118. *
  119. * @return $this
  120. */
  121. public function setId($id)
  122. {
  123. $this->id = $id;
  124. return $this;
  125. }
  126. /**
  127. * Gets id.
  128. *
  129. * @return int
  130. */
  131. public function getId()
  132. {
  133. return $this->id;
  134. }
  135. /**
  136. * Sets access.
  137. *
  138. * @param Access $access
  139. *
  140. * @return $this
  141. */
  142. public function setAccess(Access $access)
  143. {
  144. $this->access = $access;
  145. return $this;
  146. }
  147. /**
  148. * Gets access.
  149. *
  150. * @return Access
  151. */
  152. public function getAccess()
  153. {
  154. return $this->access;
  155. }
  156. /**
  157. * Sets wording.
  158. *
  159. * @param string $wording
  160. *
  161. * @return $this
  162. */
  163. public function setWording($wording)
  164. {
  165. $this->wording = $wording;
  166. return $this;
  167. }
  168. /**
  169. * Gets wording.
  170. *
  171. * @return string
  172. */
  173. public function getWording()
  174. {
  175. return $this->wording;
  176. }
  177. /**
  178. * Sets organization.
  179. *
  180. * @param Organization $organization
  181. *
  182. * @return $this
  183. */
  184. public function setOrganization(Organization $organization)
  185. {
  186. $this->organization = $organization;
  187. return $this;
  188. }
  189. /**
  190. * Gets organization.
  191. *
  192. * @return Organization
  193. */
  194. public function getOrganization()
  195. {
  196. return $this->organization;
  197. }
  198. /**
  199. * Sets amount.
  200. *
  201. * @param float $amount
  202. *
  203. * @return $this
  204. */
  205. public function setAmount($amount)
  206. {
  207. $amount = floatval($amount);
  208. $this->amount = $amount;
  209. return $this;
  210. }
  211. /**
  212. * Gets amount.
  213. *
  214. * @return float
  215. */
  216. public function getAmount()
  217. {
  218. return $this->amount;
  219. }
  220. /**
  221. * Sets paymentDate.
  222. *
  223. * @param \DateTime $paymentDate
  224. *
  225. * @return $this
  226. */
  227. public function setPaymentDate(\DateTime $paymentDate = null)
  228. {
  229. $this->paymentDate = $paymentDate;
  230. return $this;
  231. }
  232. /**
  233. * Gets paymentDate.
  234. *
  235. * @return \DateTime
  236. */
  237. public function getPaymentDate()
  238. {
  239. return $this->paymentDate ? $this->paymentDate->format('Y-m-d') : $this->paymentDate;
  240. }
  241. /**
  242. * Sets emailVisibility.
  243. *
  244. * @param bool $emailVisibility
  245. *
  246. * @return $this
  247. */
  248. public function setEmailVisibility($emailVisibility)
  249. {
  250. $this->emailVisibility = $emailVisibility;
  251. return $this;
  252. }
  253. /**
  254. * Gets emailVisibility.
  255. *
  256. * @return bool
  257. */
  258. public function getEmailVisibility()
  259. {
  260. return $this->emailVisibility;
  261. }
  262. /**
  263. * Sets logoVisibility.
  264. *
  265. * @param bool $logoVisibility
  266. *
  267. * @return $this
  268. */
  269. public function setLogoVisibility($logoVisibility)
  270. {
  271. $this->logoVisibility = $logoVisibility;
  272. return $this;
  273. }
  274. /**
  275. * Gets logoVisibility.
  276. *
  277. * @return bool
  278. */
  279. public function getLogoVisibility()
  280. {
  281. return $this->logoVisibility;
  282. }
  283. /**
  284. * Sets displayedOn.
  285. *
  286. * @param string $displayedOn
  287. *
  288. * @return $this
  289. */
  290. public function setDisplayedOn($displayedOn)
  291. {
  292. $this->displayedOn = $displayedOn;
  293. return $this;
  294. }
  295. /**
  296. * Gets displayedOn.
  297. *
  298. * @return string
  299. */
  300. public function getDisplayedOn()
  301. {
  302. return $this->displayedOn;
  303. }
  304. /**
  305. * @return bool
  306. */
  307. public function isDonorVisibility()
  308. {
  309. return $this->donorVisibility;
  310. }
  311. /**
  312. * @param bool $donorVisibility
  313. */
  314. public function setDonorVisibility($donorVisibility)
  315. {
  316. $this->donorVisibility = $donorVisibility;
  317. }
  318. /**
  319. * Set federationDisplay
  320. *
  321. * @param boolean $federationDisplay
  322. *
  323. * @return Donor
  324. */
  325. public function setFederationDisplay($federationDisplay)
  326. {
  327. $this->federationDisplay = $federationDisplay;
  328. return $this;
  329. }
  330. /**
  331. * Get federationDisplay
  332. *
  333. * @return boolean
  334. */
  335. public function getFederationDisplay()
  336. {
  337. return $this->federationDisplay;
  338. }
  339. /**
  340. * Set associationDisplay
  341. *
  342. * @param boolean $associationDisplay
  343. *
  344. * @return Donor
  345. */
  346. public function setAssociationDisplay($associationDisplay)
  347. {
  348. $this->associationDisplay = $associationDisplay;
  349. return $this;
  350. }
  351. /**
  352. * Get associationDisplay
  353. *
  354. * @return boolean
  355. */
  356. public function getAssociationDisplay()
  357. {
  358. return $this->associationDisplay;
  359. }
  360. }