OrganizationAddressPostal.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. namespace AppBundle\Entity\Organization;
  3. use AppBundle\Annotation\DefaultField;
  4. use AppBundle\Entity\Core\AddressPostal;
  5. use AppBundle\Enum\Core\AddressPostalTypeEnum;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Dunglas\ApiBundle\Annotation\Iri;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use AppBundle\Entity\Traits\TimestampableEntity;
  11. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  12. /**
  13. * Lien entre une Organization et une AdressPostal, associé à un type
  14. *
  15. * @Iri("http://schema.org/OrganizationAddressPostal")
  16. */
  17. #[ORM\Entity]
  18. #[Assert\Callback(['AppBundle\Validator\Constraints\Organization\OrganizationAddressPostalValidator', 'validate'])]
  19. class OrganizationAddressPostal
  20. {
  21. use TimestampableEntity;
  22. use CreatorUpdaterEntity;
  23. /**
  24. * @var int
  25. */
  26. #[ORM\Column(type: 'integer')]
  27. #[ORM\Id]
  28. #[ORM\GeneratedValue(strategy: 'AUTO')]
  29. #[Groups(['organizationaddresspostal', 'network_list', 'federations_list', 'networkmanagers_list_organization', 'network_artist_school_list', 'organization_details', 'organization_cotisation_steps', 'cmf_network_organizations', 'organization_params_list'])]
  30. private $id;
  31. /**
  32. * @var Organization
  33. *
  34. * @DefaultField
  35. */
  36. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization', inversedBy: 'organizationAddressPostal')]
  37. #[ORM\JoinColumn(nullable: false)]
  38. #[Assert\NotNull]
  39. #[Groups(['organizationaddresspostal'])]
  40. private $organization;
  41. /**
  42. * @var AddressPostal
  43. */
  44. #[Assert\Valid]
  45. #[ORM\OneToOne(targetEntity: 'AppBundle\Entity\Core\AddressPostal', cascade: ['persist', 'remove'], orphanRemoval: true, fetch: 'EAGER')]
  46. #[ORM\JoinColumn(nullable: false)]
  47. #[Assert\NotNull]
  48. #[Groups(['organizationaddresspostal', 'organizationaddresspostal_reference', 'network_list_organizationaddresspostal', 'federations_list_organizationaddresspostal', 'networkmanagers_list_organization', 'network_artist_school_list_organizationaddresspostal', 'organization_details_organizationaddresspostal', 'network_artist_school_list_organizationaddresspostalprincipal', 'network_artist_school_list_organizationaddresspostalcontact', 'network_artist_school_list_organizationaddresspostalbill', 'organization_cotisation_steps_organizationaddresspostal', 'template', 'cmf_network_organizations_organizationaddresspostalprincipal', 'organization_params_list_organizationaddresspostal'])]
  49. private $addressPostal;
  50. /**
  51. * @var string
  52. */
  53. #[ORM\Column(type: 'string')]
  54. #[Assert\Type(type: 'string')]
  55. #[Assert\NotNull]
  56. #[Assert\Choice(callback: ['AppBundle\Enum\Core\AddressPostalTypeEnum', 'toArray'])]
  57. #[Groups(['organizationaddresspostal', 'organizationaddresspostal_reference', 'network_list_organizationaddresspostal', 'federations_list_organizationaddresspostal', 'networkmanagers_list_organization', 'network_artist_school_list_organizationaddresspostal', 'organization_details_organizationaddresspostal', 'organization_cotisation_steps_organizationaddresspostal', 'organization_params_list_organizationaddresspostal'])]
  58. private $type;
  59. /**
  60. * Sets id.
  61. *
  62. * @param int $id
  63. *
  64. * @return $this
  65. */
  66. public function setId($id)
  67. {
  68. $this->id = $id;
  69. return $this;
  70. }
  71. /**
  72. * Gets id.
  73. *
  74. * @return int
  75. */
  76. public function getId()
  77. {
  78. return $this->id;
  79. }
  80. /**
  81. * Sets organization.
  82. *
  83. * @param Organization $organization
  84. *
  85. * @return $this
  86. */
  87. public function setOrganization(Organization $organization)
  88. {
  89. $this->organization = $organization;
  90. return $this;
  91. }
  92. /**
  93. * Gets organization.
  94. *
  95. * @return Organization
  96. */
  97. public function getOrganization()
  98. {
  99. return $this->organization;
  100. }
  101. /**
  102. * Sets address postal.
  103. *
  104. * @param AddressPostal $addressPostal
  105. *
  106. * @return $this
  107. */
  108. public function setAddressPostal(AddressPostal $addressPostal)
  109. {
  110. $this->addressPostal = $addressPostal;
  111. return $this;
  112. }
  113. /**
  114. * Gets address postal.
  115. *
  116. * @return AddressPostal
  117. */
  118. public function getAddressPostal()
  119. {
  120. return $this->addressPostal;
  121. }
  122. /**
  123. * Sets type.
  124. *
  125. * @param string $type
  126. *
  127. * @return $this
  128. */
  129. public function setType($type)
  130. {
  131. $this->type = $type;
  132. return $this;
  133. }
  134. /**
  135. * Gets type.
  136. *
  137. * @return string
  138. */
  139. public function getType()
  140. {
  141. return $this->type;
  142. }
  143. }