vendor/sulu/sulu/src/Sulu/Bundle/RouteBundle/Entity/Route.php line 27

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\RouteBundle\Entity;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use JMS\Serializer\Annotation\ExclusionPolicy;
  14. use JMS\Serializer\Annotation\Expose;
  15. use JMS\Serializer\Annotation\VirtualProperty;
  16. use Sulu\Bundle\RouteBundle\Model\RouteInterface;
  17. use Sulu\Component\Persistence\Model\AuditableInterface;
  18. use Sulu\Component\Persistence\Model\AuditableTrait;
  19. /**
  20. * Represents a concrete route in the route-pool.
  21. */
  22. #[ExclusionPolicy('all')]
  23. class Route implements RouteInterface, AuditableInterface
  24. {
  25. use AuditableTrait;
  26. /**
  27. * @var int
  28. */
  29. #[Expose]
  30. private $id;
  31. /**
  32. * @var string
  33. */
  34. #[Expose]
  35. private $path;
  36. /**
  37. * @var string
  38. */
  39. #[Expose]
  40. private $locale;
  41. /**
  42. * @var string
  43. */
  44. private $entityClass;
  45. /**
  46. * @var string
  47. */
  48. private $entityId;
  49. /**
  50. * @var bool
  51. */
  52. #[Expose]
  53. private $history = false;
  54. /**
  55. * @var RouteInterface|null
  56. */
  57. private $target;
  58. /**
  59. * @var Collection<int, RouteInterface>
  60. */
  61. protected $histories;
  62. /**
  63. * @param string $path
  64. * @param string $entityId
  65. * @param string $entityClass
  66. * @param string $locale
  67. */
  68. public function __construct($path = null, $entityId = null, $entityClass = null, $locale = null)
  69. {
  70. $this->path = $path;
  71. $this->entityId = $entityId;
  72. $this->entityClass = $entityClass;
  73. $this->locale = $locale;
  74. $this->histories = new ArrayCollection();
  75. }
  76. public function getId()
  77. {
  78. return $this->id;
  79. }
  80. public function setPath($path)
  81. {
  82. $this->path = $path;
  83. return $this;
  84. }
  85. public function getPath()
  86. {
  87. return $this->path;
  88. }
  89. public function setLocale($locale)
  90. {
  91. $this->locale = $locale;
  92. return $this;
  93. }
  94. public function getLocale()
  95. {
  96. return $this->locale;
  97. }
  98. public function getEntityClass()
  99. {
  100. return $this->entityClass;
  101. }
  102. public function setEntityClass($entityClass)
  103. {
  104. $this->entityClass = $entityClass;
  105. return $this;
  106. }
  107. public function getEntityId()
  108. {
  109. return $this->entityId;
  110. }
  111. public function setEntityId($entityId)
  112. {
  113. $this->entityId = $entityId;
  114. return $this;
  115. }
  116. public function isHistory()
  117. {
  118. return $this->history;
  119. }
  120. public function setHistory($history)
  121. {
  122. $this->history = $history;
  123. return $this;
  124. }
  125. public function getTarget()
  126. {
  127. return $this->target;
  128. }
  129. public function setTarget(?RouteInterface $target = null)
  130. {
  131. $this->target = $target;
  132. return $this;
  133. }
  134. public function removeTarget()
  135. {
  136. $this->target = null;
  137. return $this;
  138. }
  139. public function getHistories()
  140. {
  141. return $this->histories;
  142. }
  143. public function addHistory(RouteInterface $history)
  144. {
  145. $this->histories[] = $history;
  146. return $this;
  147. }
  148. #[VirtualProperty]
  149. public function getCreated()
  150. {
  151. return $this->created;
  152. }
  153. #[VirtualProperty]
  154. public function getResourcelocator()
  155. {
  156. return $this->path;
  157. }
  158. }