src/Entity/Content/Page.php line 114

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Content;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Knp\DoctrineBehaviors\Contract\Entity\TranslationInterface;
  7. use Knp\DoctrineBehaviors\Model\Translatable\TranslationTrait;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  9. use Knp\DoctrineBehaviors\Model as ORMBehaviors;
  10. use App\Traits\ECommerce\DatesInterface;
  11. use App\Traits\ECommerce\DatesTrait;
  12. /**
  13. * Page
  14. *
  15. * @ORM\Table(name="page")
  16. * @ORM\Entity(repositoryClass="App\Repository\Content\PageRepository")
  17. * @ORM\Cache(usage="READ_ONLY", region="public")
  18. */
  19. class Page implements DatesInterface, TranslatableInterface
  20. {
  21. use ORMBehaviors\Translatable\TranslatableTrait;
  22. use DatesTrait {
  23. DatesTrait::__construct as __DT_construct;
  24. }
  25. /**
  26. * @var int
  27. *
  28. * @ORM\Column(name="id", type="integer")
  29. * @ORM\Id
  30. * @ORM\GeneratedValue(strategy="AUTO")
  31. */
  32. private $id;
  33. /**
  34. * @var bool
  35. *
  36. * @ORM\Column(name="home", type="boolean", options={"default":false})
  37. */
  38. private $home = false;
  39. /**
  40. * @var Page
  41. *
  42. * @ORM\ManyToOne(targetEntity="App\Entity\Content\Page", inversedBy="children")
  43. * @ORM\JoinColumn(name="parent", referencedColumnName="id", nullable=true)
  44. */
  45. private $parent;
  46. /**
  47. * @var ArrayCollection
  48. *
  49. * @ORM\OneToMany(targetEntity="App\Entity\Content\Page", mappedBy="parent")
  50. */
  51. private $children;
  52. /**
  53. * @var string
  54. *
  55. * @ORM\Column(name="style", type="text", nullable=true)
  56. */
  57. private $style;
  58. /**
  59. * Constructor
  60. */
  61. public function __construct()
  62. {
  63. $this->__DT_construct();
  64. $this->children = new ArrayCollection();
  65. }
  66. /**
  67. * Get id
  68. *
  69. * @return int
  70. */
  71. public function getId()
  72. {
  73. return $this->id;
  74. }
  75. /**
  76. * Set home
  77. *
  78. * @param string $home
  79. */
  80. public function setHome($home): static
  81. {
  82. $this->home = $home;
  83. return $this;
  84. }
  85. /**
  86. * Get home
  87. *
  88. * @return string
  89. */
  90. public function getHome()
  91. {
  92. return $this->home;
  93. }
  94. /**
  95. * Set parent
  96. *
  97. *
  98. */
  99. public function setParent(Page $parent = null): static
  100. {
  101. $this->parent = $parent;
  102. return $this;
  103. }
  104. /**
  105. * Get parent
  106. *
  107. * @return Page
  108. */
  109. public function getParent()
  110. {
  111. return $this->parent;
  112. }
  113. /**
  114. * Add child
  115. *
  116. *
  117. */
  118. public function addChild(Page $child): static
  119. {
  120. $this->children[] = $child;
  121. return $this;
  122. }
  123. /**
  124. * Remove child
  125. */
  126. public function removeChild(Page $child): void
  127. {
  128. $this->children->removeElement($child);
  129. }
  130. /**
  131. * Get children
  132. *
  133. * @return Collection
  134. */
  135. public function getChildren()
  136. {
  137. return $this->children;
  138. }
  139. /**
  140. * Set style
  141. *
  142. * @param string $style
  143. */
  144. public function setStyle($style): static
  145. {
  146. $this->style = $style;
  147. return $this;
  148. }
  149. /**
  150. * Get style
  151. */
  152. public function getStyle(): string
  153. {
  154. return (string)$this->style;
  155. }
  156. }