<?phpnamespace App\Entity;use App\Entity\Traits\ActiveTrait;use App\Entity\Traits\DeleteTrait;use App\Entity\Traits\LinkTrait;use App\Entity\Traits\MetaTrait;use App\Entity\Traits\TitleAndContentTrait;use App\Entity\Traits\TranslateTrait;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Gedmo\Mapping\Annotation as Gedmo;use Gedmo\Timestampable\Traits\TimestampableEntity;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;/** * Slider. * * @Gedmo\Loggable * * @Gedmo\TranslationEntity(class="App\Entity\SliderTranslations") */#[UniqueEntity(fields: ['identifier'], errorPath: 'identifier', message: 'A slider has already be created with that identifier.')]#[ORM\Entity(repositoryClass: \App\Repository\SliderRepository::class)]#[ORM\HasLifecycleCallbacks]#[ORM\Table(name: 'slider')]class Slider{ use TitleAndContentTrait; use LinkTrait; use MetaTrait; use ActiveTrait; use DeleteTrait; use TimestampableEntity; use TranslateTrait; #[ORM\Column(name: 'id', type: 'integer')] #[ORM\Id] #[ORM\GeneratedValue(strategy: 'AUTO')] private int $id; #[ORM\Column(name: 'identifier', type: 'string', length: 255)] private ?string $identifier = null; #[ORM\OneToMany(targetEntity: 'SliderImages', mappedBy: 'slider')] #[ORM\OrderBy(['position' => 'ASC'])] private Collection $images; #[ORM\ManyToMany(targetEntity: \App\Entity\Page::class, inversedBy: 'slider')] private Collection $pages; /** * Constructor. */ public function __construct() { $this->images = new ArrayCollection(); $this->pages = new ArrayCollection(); } public function getFilePath(): string { return 'userfiles/images/slider'; } /** * Get id. * * @return int */ public function getId() { return $this->id; } /** * Set identifier. * * @param string $identifier * * @return Slider */ public function setIdentifier($identifier) { $this->identifier = $identifier; return $this; } /** * Get identifier. * * @return string */ public function getIdentifier() { return $this->identifier; } /** * Add images. * * @return Slider */ public function addImage(SliderImages $images) { $this->images[] = $images; return $this; } /** * Remove images. */ public function removeImage(SliderImages $images) { $this->images->removeElement($images); } /** * Get images. * * @return ArrayCollection */ public function getImages() { $activeImages = []; foreach ($this->images as $image) { if (! $image->isDeleted()) { $activeImages[] = $image; } } return $this->images; } public function getActiveImages() { return $this->images; } /** * Add pages. * * @return Slider */ public function addPage(Page $page) { $this->pages[] = $page; return $this; } /** * Remove pages. */ public function removePage(Page $page) { $this->pages->removeElement($page); } /** * Get pages. * * @return ArrayCollection */ public function getPages() { return $this->pages; } // REQUIRED BY THE META LINKS TRAIT - NOT REALLY NEEDED HERE BUT WHATEVS :) public function getLinkedPageId(): int { return 1; }}