<?phpnamespace App\Entity;use App\Entity\CMS\CmsContentTrait;use App\Entity\Common\AnimationGroup;use App\Entity\EntityTrait\EntityBaseInformationTrait;use App\Entity\EntityTrait\EntityIdentityTrait;use App\Entity\EntityTrait\EntitySoftDeletableTrait;use App\Entity\EntityTrait\EntityTimestampableTrait;use App\Entity\EntityTrait\ImageTrait;use DateTimeImmutable;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Gedmo\Mapping\Annotation as Gedmo;/** * @ORM\Entity(repositoryClass="App\Repository\StaticPageRepository") */class StaticPage{ use CmsContentTrait; use EntityBaseInformationTrait; use EntityIdentityTrait; use EntitySoftDeletableTrait; use EntityTimestampableTrait; use ImageTrait; /** * @ORM\ManyToMany(targetEntity="App\Entity\Common\AnimationGroup", cascade={"persist", "remove"}) */ private $animationGroups; /** * @ORM\OneToMany(targetEntity="App\Entity\StaticPage", mappedBy="parentPage", cascade={"persist", "remove"}) */ private $subPages; /** * @ORM\ManyToOne(targetEntity="App\Entity\StaticPage", inversedBy="subPages") */ private $parentPage; /** * @ORM\Column(type="string", nullable=true) */ private $relativeUrl; /** * @ORM\Column(type="text", nullable=true) */ private $shortDescription; public function __construct() { $this->animationGroups = new ArrayCollection(); $this->baseInformation = new BaseInformation(); $this->createdAt = new DateTimeImmutable(); $this->updatedAt = new DateTimeImmutable(); $this->subPages = new ArrayCollection(); } public function getAnimationGroups(): ?Collection { return $this->animationGroups; } public function setAnimationGroups(?Collection $animationGroups = null): void { $this->animationGroups->clear(); $this->animationGroups = $animationGroups; } public function addAnimationGroup(AnimationGroup $animationGroup): void { $this->animationGroups[] = $animationGroup; } public function removeAnimationGroup(AnimationGroup $animationGroup): void { $this->animationGroups->removeElement($animationGroup); } public function getSubPages(): ?Collection { return $this->subPages; } public function setSubPages(?Collection $subPages = null): void { $subPages->removeElement($this); $this->subPages->clear(); $this->subPages = $subPages; foreach ($subPages as $subPage) { if ($subPage->getParentPage() !== $this) { $subPage->setParentPage($this); } } } public function addSubPage(StaticPage $subPage): void { if ($subPage !== $this) { $this->subPages[] = $subPage; if ($subPage->getParentPage() !== $this) { $subPage->setParentPage($this); } } } public function removeSubPage(StaticPage $subPage): void { $this->subPages->removeElement($subPage); } public function getParentPage(): ?StaticPage { return $this->parentPage; } public function setParentPage(?StaticPage $parentPage = null): void { $this->parentPage = $parentPage; } public function setShortDescription(?string $shortDescription = null): void { $this->shortDescription = $shortDescription; } public function getShortDescription(): ?string { return $this->shortDescription; } public function getRelativeUrl(): ?string { return $this->relativeUrl; } public function setRelativeUrl(?string $relativeUrl = null): void { $this->relativeUrl = $relativeUrl; } public function getChilds (): ?Collection { return $this->subPages; } public function getBreadcrumbs() : ?array { $bread[$this->getBaseInformation()->getName()] = $this->getRelativeUrl(); if (!empty($this->getParentPage())) { return array_merge($this->getParentPage()->getBreadcrumbs(), $bread); } return $bread; }}