vendor/sulu/sulu/src/Sulu/Bundle/ContactBundle/Entity/EmailType.php line 20

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 JMS\Serializer\Annotation\Exclude;
  12. use JMS\Serializer\Annotation\Groups;
  13. /**
  14.  * EmailType.
  15.  */
  16. class EmailType implements \JsonSerializable
  17. {
  18.     /**
  19.      * @var string
  20.      *
  21.      * @Groups({"fullAccount", "fullContact", "frontend"})
  22.      */
  23.     private $name;
  24.     /**
  25.      * @var int
  26.      *
  27.      * @Groups({"fullAccount", "fullContact", "frontend"})
  28.      */
  29.     private $id;
  30.     /**
  31.      * @var \Doctrine\Common\Collections\Collection
  32.      *
  33.      * @Exclude
  34.      */
  35.     private $emails;
  36.     /**
  37.      * Constructor.
  38.      */
  39.     public function __construct()
  40.     {
  41.         $this->emails = new \Doctrine\Common\Collections\ArrayCollection();
  42.     }
  43.     /**
  44.      * To force id = 1 in load fixtures.
  45.      *
  46.      * @param int $id
  47.      */
  48.     public function setId($id)
  49.     {
  50.         $this->id $id;
  51.     }
  52.     /**
  53.      * Set name.
  54.      *
  55.      * @param string $name
  56.      *
  57.      * @return EmailType
  58.      */
  59.     public function setName($name)
  60.     {
  61.         $this->name $name;
  62.         return $this;
  63.     }
  64.     /**
  65.      * Get name.
  66.      *
  67.      * @return string
  68.      */
  69.     public function getName()
  70.     {
  71.         return $this->name;
  72.     }
  73.     /**
  74.      * Get id.
  75.      *
  76.      * @return int
  77.      */
  78.     public function getId()
  79.     {
  80.         return $this->id;
  81.     }
  82.     /**
  83.      * Add emails.
  84.      *
  85.      * @return EmailType
  86.      */
  87.     public function addEmail(Email $emails)
  88.     {
  89.         $this->emails[] = $emails;
  90.         return $this;
  91.     }
  92.     /**
  93.      * Remove emails.
  94.      */
  95.     public function removeEmail(Email $emails)
  96.     {
  97.         $this->emails->removeElement($emails);
  98.     }
  99.     /**
  100.      * Get emails.
  101.      *
  102.      * @return \Doctrine\Common\Collections\Collection
  103.      */
  104.     public function getEmails()
  105.     {
  106.         return $this->emails;
  107.     }
  108.     /**
  109.      * (PHP 5 &gt;= 5.4.0)<br/>
  110.      * Specify data which should be serialized to JSON.
  111.      *
  112.      * @see http://php.net/manual/en/jsonserializable.jsonserialize.php
  113.      *
  114.      * @return mixed data which can be serialized by <b>json_encode</b>,
  115.      *               which is a value of any type other than a resource
  116.      */
  117.     #[\ReturnTypeWillChange]
  118.     public function jsonSerialize()
  119.     {
  120.         return [
  121.             'id' => $this->getId(),
  122.             'name' => $this->getName(),
  123.         ];
  124.     }
  125. }