CompanyPerson.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. namespace AppBundle\Entity\Person;
  3. use AppBundle\Entity\AccessAndFunction\Access;
  4. use AppBundle\Entity\Traits\ActivityPeriodTrait;
  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. /**
  12. * Rôle d'un Access d'une personne physique dans un Access d'une personne morale
  13. *
  14. * @Iri("http://schema.org/CompanyPerson")
  15. */
  16. #[ORM\Entity]
  17. class CompanyPerson
  18. {
  19. use TimestampableEntity;
  20. use CreatorUpdaterEntity;
  21. use ActivityPeriodTrait;
  22. /**
  23. * @var int
  24. */
  25. #[ORM\Column(type: 'integer')]
  26. #[ORM\Id]
  27. #[ORM\GeneratedValue(strategy: 'AUTO')]
  28. #[Groups(['othercontact_list', 'othercontact_list_companypersoncompany', 'companyperson', 'access_details', 'morals_list'])]
  29. private $id;
  30. /**
  31. * @var Access
  32. */
  33. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'companyPersonAccesses')]
  34. #[ORM\JoinColumn(nullable: false)]
  35. #[Assert\NotNull]
  36. #[Groups(['companyperson', 'othercontact_list_companypersoncompany', 'access_details_companypersonaccesses', 'access_details_companypersoncompany'])]
  37. private $company;
  38. /**
  39. * @var Access
  40. */
  41. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'companyPersonCompany')]
  42. #[ORM\JoinColumn(nullable: false)]
  43. #[Assert\NotNull]
  44. #[Groups(['companyperson', 'access_details_companypersonaccesses', 'morals_list_companypersonaccesses'])]
  45. private $access;
  46. /**
  47. * @var string
  48. */
  49. #[ORM\Column(type: 'text', nullable: true)]
  50. #[Assert\Type(type: 'string')]
  51. #[Groups(['companyperson', 'othercontact_list_companypersoncompany', 'access_details_companypersonaccesses', 'access_details_companypersoncompany'])]
  52. private $mission;
  53. /**
  54. * @var string
  55. */
  56. #[Groups(['othercontact_list_companypersoncompany'])]
  57. private $companyFullLabelTemplate;
  58. /**
  59. * Sets id.
  60. *
  61. * @param int $id
  62. *
  63. * @return $this
  64. */
  65. public function setId($id)
  66. {
  67. $this->id = $id;
  68. return $this;
  69. }
  70. /**
  71. * Gets id.
  72. *
  73. * @return int
  74. */
  75. public function getId()
  76. {
  77. return $this->id;
  78. }
  79. /**
  80. * Sets company.
  81. *
  82. * @param Access $company
  83. *
  84. * @return $this
  85. */
  86. public function setCompany(Access $company)
  87. {
  88. $this->company = $company;
  89. return $this;
  90. }
  91. /**
  92. * Gets company.
  93. *
  94. * @return Access
  95. */
  96. public function getCompany()
  97. {
  98. return $this->company;
  99. }
  100. /**
  101. * Sets person.
  102. *
  103. * @param Access $access
  104. *
  105. * @return $this
  106. */
  107. public function setAccess(Access $access)
  108. {
  109. $this->access = $access;
  110. return $this;
  111. }
  112. /**
  113. * Gets person.
  114. *
  115. * @return Access
  116. */
  117. public function getAccess()
  118. {
  119. return $this->access;
  120. }
  121. /**
  122. * Sets mission.
  123. *
  124. * @param string $mission
  125. *
  126. * @return $this
  127. */
  128. public function setMission($mission)
  129. {
  130. $this->mission = $mission;
  131. return $this;
  132. }
  133. /**
  134. * Gets mission.
  135. *
  136. * @return string
  137. */
  138. public function getMission()
  139. {
  140. return $this->mission;
  141. }
  142. /**
  143. * Gets full label.
  144. *
  145. * @return string
  146. */
  147. public function getCompanyFullLabelTemplate()
  148. {
  149. return [
  150. $this->getCompany()->getPerson()->getName(),
  151. $this->getMission()
  152. ];
  153. }
  154. }