vendor/sulu/sulu/src/Sulu/Bundle/ContactBundle/Entity/FaxType.php line 22

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