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

  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.  */
  23. class SocialMediaProfile
  24. {
  25.     /**
  26.      * @var int
  27.      */
  28.     private $id;
  29.     /**
  30.      * @var string
  31.      */
  32.     private $username;
  33.     /**
  34.      * @var SocialMediaProfileType
  35.      */
  36.     private $socialMediaProfileType;
  37.     /**
  38.      * @var Collection<int, ContactInterface>
  39.      */
  40.     private $contacts;
  41.     /**
  42.      * @var Collection<int, AccountInterface>
  43.      */
  44.     private $accounts;
  45.     /**
  46.      * Constructor.
  47.      */
  48.     public function __construct()
  49.     {
  50.         $this->contacts = new ArrayCollection();
  51.         $this->accounts = new ArrayCollection();
  52.     }
  53.     /**
  54.      * @VirtualProperty()
  55.      * @SerializedName("id")
  56.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  57.      *
  58.      * @return int
  59.      */
  60.     public function getId()
  61.     {
  62.         return $this->id;
  63.     }
  64.     /**
  65.      * @param string $username
  66.      *
  67.      * @return SocialMediaProfile
  68.      */
  69.     public function setUsername($username)
  70.     {
  71.         // Limit to maximal sql column length.
  72.         $this->username \substr($username0255);
  73.         return $this;
  74.     }
  75.     /**
  76.      * @VirtualProperty()
  77.      * @SerializedName("username")
  78.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  79.      *
  80.      * @return string
  81.      */
  82.     public function getUsername()
  83.     {
  84.         return $this->username;
  85.     }
  86.     /**
  87.      * @return SocialMediaProfile
  88.      */
  89.     public function setSocialMediaProfileType(SocialMediaProfileType $socialMediaProfileType)
  90.     {
  91.         $this->socialMediaProfileType $socialMediaProfileType;
  92.         return $this;
  93.     }
  94.     /**
  95.      * @Serializer\VirtualProperty()
  96.      * @Serializer\SerializedName("socialMediaProfileType")
  97.      * @Groups({"fullAccount", "fullContact"})
  98.      *
  99.      * @return SocialMediaProfileType
  100.      */
  101.     public function getSocialMediaProfileType()
  102.     {
  103.         return $this->socialMediaProfileType;
  104.     }
  105.     /**
  106.      * @return SocialMediaProfile
  107.      */
  108.     public function addContact(ContactInterface $contacts)
  109.     {
  110.         $this->contacts[] = $contacts;
  111.         return $this;
  112.     }
  113.     public function removeContact(ContactInterface $contacts)
  114.     {
  115.         $this->contacts->removeElement($contacts);
  116.     }
  117.     /**
  118.      * @return Collection<int, ContactInterface>
  119.      */
  120.     public function getContacts()
  121.     {
  122.         return $this->contacts;
  123.     }
  124.     /**
  125.      * @return SocialMediaProfile
  126.      */
  127.     public function addAccount(AccountInterface $account)
  128.     {
  129.         $this->accounts[] = $account;
  130.         return $this;
  131.     }
  132.     public function removeAccount(AccountInterface $account)
  133.     {
  134.         $this->accounts->removeElement($account);
  135.     }
  136.     /**
  137.      * @return Collection<int, AccountInterface>
  138.      */
  139.     public function getAccounts()
  140.     {
  141.         return $this->accounts;
  142.     }
  143. }