NetworkOrganization.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. namespace AppBundle\Entity\Network;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Dunglas\ApiBundle\Annotation\Iri;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use AppBundle\Entity\Organization\Organization;
  8. use AppBundle\Entity\Traits\TimestampableEntity;
  9. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  10. use AppBundle\Entity\Traits\ActivityPeriodTrait;
  11. /**
  12. * Fait le lien entre une Organization et un Network
  13. *
  14. * @Iri("http://schema.org/NetworkOrganization")
  15. */
  16. #[ORM\Entity(repositoryClass: 'AppBundle\Entity\Network\Repository\NetworkOrganizationRepository')]
  17. #[ORM\Table(name: 'NetworkOrganization')]
  18. #[ORM\Index(name: 'viewIndex', columns: ['endDate'])]
  19. class NetworkOrganization
  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(['networkorganization', 'network_list', 'organization_create', 'organization_details', 'organization_params_list'])]
  31. private $id;
  32. /**
  33. * @var Network
  34. */
  35. #[ORM\ManyToOne(targetEntity: 'Network', inversedBy: 'organizations')]
  36. #[ORM\JoinColumn(name: 'network_id', referencedColumnName: 'id', nullable: false)]
  37. #[Assert\NotNull]
  38. #[Groups(['networkorganization', 'organization_create_network', 'organization_details_network', 'organization_params_list_network'])]
  39. private $network;
  40. /**
  41. * @var Organization
  42. */
  43. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization', inversedBy: 'network')]
  44. #[ORM\JoinColumn(name: 'organization_id', referencedColumnName: 'id', nullable: false)]
  45. #[Assert\NotNull]
  46. #[Groups(['networkorganization'])]
  47. private $organization;
  48. /**
  49. * @var Organization
  50. */
  51. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization', inversedBy: 'networkChild')]
  52. #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id', nullable: true)]
  53. #[Assert\NotNull]
  54. #[Groups(['networkorganization', 'organization_params_list_network'])]
  55. private $parent;
  56. /**
  57. * @var string
  58. */
  59. #[ORM\Column(type: 'string', nullable: true)]
  60. #[ORM\JoinColumn(nullable: true)]
  61. #[Assert\Type(type: 'string')]
  62. #[Assert\Choice(callback: ['\AppBundle\Enum\Network\LeadingCauseEnum', 'toArray'])]
  63. #[Groups(['networkorganization', 'organization_params_list_network'])]
  64. private $leadingCause;
  65. /**
  66. * Sets id.
  67. *
  68. * @param int $id
  69. *
  70. * @return $this
  71. */
  72. public function setId($id)
  73. {
  74. $this->id = $id;
  75. return $this;
  76. }
  77. /**
  78. * Gets id.
  79. *
  80. * @return int
  81. */
  82. public function getId()
  83. {
  84. return $this->id;
  85. }
  86. /**
  87. * Sets network.
  88. *
  89. * @param Network $network
  90. *
  91. * @return $this
  92. */
  93. public function setNetwork(Network $network)
  94. {
  95. $this->network = $network;
  96. return $this;
  97. }
  98. /**
  99. * Gets network.
  100. *
  101. * @return Network
  102. */
  103. public function getNetwork()
  104. {
  105. return $this->network;
  106. }
  107. /**
  108. * Sets organization.
  109. *
  110. * @param Organization $organization
  111. *
  112. * @return $this
  113. */
  114. public function setOrganization(Organization $organization)
  115. {
  116. $this->organization = $organization;
  117. return $this;
  118. }
  119. /**
  120. * Gets organization.
  121. *
  122. * @return Organization
  123. */
  124. public function getOrganization()
  125. {
  126. return $this->organization;
  127. }
  128. /**
  129. * Sets parent.
  130. *
  131. * @param Organization $parent
  132. *
  133. * @return $this
  134. */
  135. public function setParent(Organization $parent)
  136. {
  137. $this->parent = $parent;
  138. return $this;
  139. }
  140. /**
  141. * Gets parent.
  142. *
  143. * @return Organization
  144. */
  145. public function getParent()
  146. {
  147. return $this->parent;
  148. }
  149. /**
  150. * Sets leadingCause.
  151. *
  152. * @param string $leadingCause
  153. *
  154. * @return $this
  155. */
  156. public function setLeadingCause($leadingCause)
  157. {
  158. $this->leadingCause = $leadingCause;
  159. return $this;
  160. }
  161. /**
  162. * Gets leadingCause.
  163. *
  164. * @return string
  165. */
  166. public function getLeadingCause()
  167. {
  168. return $this->leadingCause;
  169. }
  170. }