vendor/sulu/sulu/src/Sulu/Bundle/ContactBundle/Entity/SocialMediaProfile.php line 26

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of Sulu.
  4. *
  5. * (c) Sulu GmbH
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Sulu\Bundle\ContactBundle\Entity;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use JMS\Serializer\Annotation as Serializer;
  14. use JMS\Serializer\Annotation\ExclusionPolicy;
  15. use JMS\Serializer\Annotation\Groups;
  16. use JMS\Serializer\Annotation\SerializedName;
  17. use JMS\Serializer\Annotation\VirtualProperty;
  18. /**
  19. * Social media profile belonging to account or contact.
  20. */
  21. #[ExclusionPolicy('All')]
  22. class SocialMediaProfile
  23. {
  24. /**
  25. * @var int
  26. */
  27. private $id;
  28. /**
  29. * @var string
  30. */
  31. private $username;
  32. /**
  33. * @var SocialMediaProfileType
  34. */
  35. private $socialMediaProfileType;
  36. /**
  37. * @var Collection<int, ContactInterface>
  38. */
  39. private $contacts;
  40. /**
  41. * @var Collection<int, AccountInterface>
  42. */
  43. private $accounts;
  44. /**
  45. * Constructor.
  46. */
  47. public function __construct()
  48. {
  49. $this->contacts = new ArrayCollection();
  50. $this->accounts = new ArrayCollection();
  51. }
  52. /**
  53. * @return int
  54. */
  55. #[VirtualProperty]
  56. #[SerializedName('id')]
  57. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  58. public function getId()
  59. {
  60. return $this->id;
  61. }
  62. /**
  63. * @param string $username
  64. *
  65. * @return SocialMediaProfile
  66. */
  67. public function setUsername($username)
  68. {
  69. // Limit to maximal sql column length.
  70. $this->username = \substr($username, 0, 255);
  71. return $this;
  72. }
  73. /**
  74. * @return string
  75. */
  76. #[VirtualProperty]
  77. #[SerializedName('username')]
  78. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  79. public function getUsername()
  80. {
  81. return $this->username;
  82. }
  83. /**
  84. * @return SocialMediaProfile
  85. */
  86. public function setSocialMediaProfileType(SocialMediaProfileType $socialMediaProfileType)
  87. {
  88. $this->socialMediaProfileType = $socialMediaProfileType;
  89. return $this;
  90. }
  91. /**
  92. * @return SocialMediaProfileType
  93. */
  94. #[Serializer\VirtualProperty]
  95. #[Serializer\SerializedName('socialMediaProfileType')]
  96. #[Groups(['fullAccount', 'fullContact'])]
  97. public function getSocialMediaProfileType()
  98. {
  99. return $this->socialMediaProfileType;
  100. }
  101. /**
  102. * @return SocialMediaProfile
  103. */
  104. public function addContact(ContactInterface $contacts)
  105. {
  106. $this->contacts[] = $contacts;
  107. return $this;
  108. }
  109. public function removeContact(ContactInterface $contacts)
  110. {
  111. $this->contacts->removeElement($contacts);
  112. }
  113. /**
  114. * @return Collection<int, ContactInterface>
  115. */
  116. public function getContacts()
  117. {
  118. return $this->contacts;
  119. }
  120. /**
  121. * @return SocialMediaProfile
  122. */
  123. public function addAccount(AccountInterface $account)
  124. {
  125. $this->accounts[] = $account;
  126. return $this;
  127. }
  128. public function removeAccount(AccountInterface $account)
  129. {
  130. $this->accounts->removeElement($account);
  131. }
  132. /**
  133. * @return Collection<int, AccountInterface>
  134. */
  135. public function getAccounts()
  136. {
  137. return $this->accounts;
  138. }
  139. }