vendor/sulu/sulu/src/Sulu/Bundle/WebsiteBundle/Entity/Analytics.php line 19

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\WebsiteBundle\Entity;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use JMS\Serializer\Annotation\Exclude;
  14. use JMS\Serializer\Annotation\VirtualProperty;
  15. class Analytics implements AnalyticsInterface
  16. {
  17. /**
  18. * @var int
  19. */
  20. private $id;
  21. /**
  22. * @var string
  23. */
  24. private $title;
  25. /**
  26. * @var bool
  27. */
  28. private $allDomains;
  29. /**
  30. * @var mixed
  31. */
  32. #[Exclude]
  33. private $content;
  34. /**
  35. * @var string
  36. */
  37. private $type;
  38. /**
  39. * @var string
  40. */
  41. private $webspaceKey;
  42. /**
  43. * @var Collection<int, Domain>
  44. */
  45. #[Exclude]
  46. private $domains;
  47. public function __construct()
  48. {
  49. $this->domains = new ArrayCollection();
  50. }
  51. public function getId(): ?int
  52. {
  53. return $this->id;
  54. }
  55. public function setTitle(string $title): AnalyticsInterface
  56. {
  57. $this->title = $title;
  58. return $this;
  59. }
  60. public function getTitle(): string
  61. {
  62. return $this->title;
  63. }
  64. public function setAllDomains(bool $allDomains): AnalyticsInterface
  65. {
  66. $this->allDomains = $allDomains;
  67. return $this;
  68. }
  69. public function isAllDomains(): bool
  70. {
  71. return $this->allDomains;
  72. }
  73. public function setContent($content): AnalyticsInterface
  74. {
  75. $this->content = $content;
  76. return $this;
  77. }
  78. public function getContent()
  79. {
  80. return $this->content;
  81. }
  82. public function setType(string $type): AnalyticsInterface
  83. {
  84. $this->type = $type;
  85. return $this;
  86. }
  87. public function getType(): string
  88. {
  89. return $this->type;
  90. }
  91. public function setWebspaceKey(string $webspaceKey): AnalyticsInterface
  92. {
  93. $this->webspaceKey = $webspaceKey;
  94. return $this;
  95. }
  96. public function getWebspaceKey(): string
  97. {
  98. return $this->webspaceKey;
  99. }
  100. public function addDomain(Domain $domain): AnalyticsInterface
  101. {
  102. if ($this->domains->contains($domain)) {
  103. return $this;
  104. }
  105. $this->domains[] = $domain;
  106. return $this;
  107. }
  108. public function removeDomain(Domain $domain): AnalyticsInterface
  109. {
  110. $this->domains->removeElement($domain);
  111. return $this;
  112. }
  113. public function clearDomains(): AnalyticsInterface
  114. {
  115. $this->domains->clear();
  116. return $this;
  117. }
  118. /**
  119. * @return Collection<int, string>|null
  120. */
  121. #[VirtualProperty]
  122. public function getDomains(): ?Collection
  123. {
  124. if (0 === \count($this->domains)) {
  125. return null;
  126. }
  127. return $this->domains->map(function(Domain $domain) {
  128. return $domain->getUrl();
  129. });
  130. }
  131. }