src/Entity/Slider.php line 28

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\SliderRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use ApiPlatform\Metadata\ApiFilter;
  10. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. #[ORM\Entity(repositoryClassSliderRepository::class)]
  13. #[ApiResource(
  14.     normalizationContext: ['groups' => ['slider:read']],
  15.     denormalizationContext: ['groups' => ['slider:write']],
  16.     order: ['id' => 'DESC'],
  17. )]
  18. #[ApiFilter(
  19.     SearchFilter::class, 
  20.     properties: [
  21.         'slug' => 'ipartial'
  22.         'name' => 'ipartial'
  23.     ]
  24. )]
  25. class Slider
  26. {
  27.     #[ORM\Id]
  28.     #[ORM\GeneratedValue]
  29.     #[ORM\Column]
  30.     #[Groups(['slider:read''slider:write''page:read''pageInfo:read'])]
  31.     private ?int $id null;
  32.     #[ORM\Column(length255nullabletrue)]
  33.     #[Groups(['slider:read''slider:write''page:read''pageInfo:read'])]
  34.     private ?string $name null;
  35.     #[ORM\Column(length100nullabletrue)]
  36.     #[Groups(['slider:read''slider:write''page:read''pageInfo:read'])]
  37.     private ?string $slug null;
  38.     #[ORM\Column(typeTypes::TEXT)]
  39.     #[Groups(['slider:read''slider:write''page:read''pageInfo:read'])]
  40.     private ?string $content null;
  41.     #[ORM\OneToMany(mappedBy'slider'targetEntityPageInfos::class)]
  42.     #[Groups(['slider:read''slider:write'])]
  43.     private Collection $pageInfos;
  44.     #[ORM\OneToMany(mappedBy'slider'targetEntityProjects::class)]
  45.     #[Groups(['slider:read''slider:write'])]
  46.     private Collection $projects;
  47.     #[ORM\OneToMany(mappedBy'slider'targetEntitySlide::class)]
  48.     #[Groups(['slider:read''slider:write''page:read''pageInfo:read'])]
  49.     private Collection $slides;
  50.     #[ORM\OneToMany(mappedBy'slider'targetEntityPages::class)]
  51.     private Collection $pages;
  52.     #[Groups(['slider:read''slider:write''page:read''pageInfo:read'])]
  53.     #[ORM\ManyToOne(inversedBy'sliders')]
  54.     private ?Languages $language null;
  55.     #[Groups(['slider:read''slider:write''page:read''pageInfo:read'])]
  56.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'translations')]
  57.     private ?self $translation null;
  58.     /**
  59.      * @var Collection<int, self>
  60.      */
  61.     #[Groups(['slider:read''slider:write''page:read''pageInfo:read'])]
  62.     #[ORM\OneToMany(mappedBy'translation'targetEntityself::class)]
  63.     private Collection $translations;
  64.     public function __construct()
  65.     {
  66.         $this->pageInfos = new ArrayCollection();
  67.         $this->projects = new ArrayCollection();
  68.         $this->slides = new ArrayCollection();
  69.         $this->pages = new ArrayCollection();
  70.         $this->translations = new ArrayCollection();
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getName(): ?string
  77.     {
  78.         return $this->name;
  79.     }
  80.     public function setName(?string $name): static
  81.     {
  82.         $this->name $name;
  83.         return $this;
  84.     }
  85.     public function getSlug(): ?string
  86.     {
  87.         return $this->slug;
  88.     }
  89.     public function setSlug(?string $slug): static
  90.     {
  91.         $this->slug $slug;
  92.         return $this;
  93.     }
  94.     public function getContent(): ?string
  95.     {
  96.         return $this->content;
  97.     }
  98.     public function setContent(string $content): static
  99.     {
  100.         $this->content $content;
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection<int, PageInfos>
  105.      */
  106.     public function getPageInfos(): Collection
  107.     {
  108.         return $this->pageInfos;
  109.     }
  110.     public function addPageInfo(PageInfos $pageInfo): static
  111.     {
  112.         if (!$this->pageInfos->contains($pageInfo)) {
  113.             $this->pageInfos->add($pageInfo);
  114.             $pageInfo->setSlider($this);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removePageInfo(PageInfos $pageInfo): static
  119.     {
  120.         if ($this->pageInfos->removeElement($pageInfo)) {
  121.             // set the owning side to null (unless already changed)
  122.             if ($pageInfo->getSlider() === $this) {
  123.                 $pageInfo->setSlider(null);
  124.             }
  125.         }
  126.         return $this;
  127.     }
  128.     /**
  129.      * @return Collection<int, Projects>
  130.      */
  131.     public function getProjects(): Collection
  132.     {
  133.         return $this->projects;
  134.     }
  135.     public function addProject(Projects $project): static
  136.     {
  137.         if (!$this->projects->contains($project)) {
  138.             $this->projects->add($project);
  139.             $project->setSlider($this);
  140.         }
  141.         return $this;
  142.     }
  143.     public function removeProject(Projects $project): static
  144.     {
  145.         if ($this->projects->removeElement($project)) {
  146.             // set the owning side to null (unless already changed)
  147.             if ($project->getSlider() === $this) {
  148.                 $project->setSlider(null);
  149.             }
  150.         }
  151.         return $this;
  152.     }
  153.     /**
  154.      * @return Collection<int, Slide>
  155.      */
  156.     public function getSlides(): Collection
  157.     {
  158.         return $this->slides;
  159.     }
  160.     public function addSlide(Slide $slide): static
  161.     {
  162.         if (!$this->slides->contains($slide)) {
  163.             $this->slides->add($slide);
  164.             $slide->setSlider($this);
  165.         }
  166.         return $this;
  167.     }
  168.     public function removeSlide(Slide $slide): static
  169.     {
  170.         if ($this->slides->removeElement($slide)) {
  171.             // set the owning side to null (unless already changed)
  172.             if ($slide->getSlider() === $this) {
  173.                 $slide->setSlider(null);
  174.             }
  175.         }
  176.         return $this;
  177.     }
  178.     /**
  179.      * @return Collection<int, Pages>
  180.      */
  181.     public function getPages(): Collection
  182.     {
  183.         return $this->pages;
  184.     }
  185.     public function addPage(Pages $page): static
  186.     {
  187.         if (!$this->pages->contains($page)) {
  188.             $this->pages->add($page);
  189.             $page->setSlider($this);
  190.         }
  191.         return $this;
  192.     }
  193.     public function removePage(Pages $page): static
  194.     {
  195.         if ($this->pages->removeElement($page)) {
  196.             // set the owning side to null (unless already changed)
  197.             if ($page->getSlider() === $this) {
  198.                 $page->setSlider(null);
  199.             }
  200.         }
  201.         return $this;
  202.     }
  203.     public function getLanguage(): ?Languages
  204.     {
  205.         return $this->language;
  206.     }
  207.     public function setLanguage(?Languages $language): static
  208.     {
  209.         $this->language $language;
  210.         return $this;
  211.     }
  212.     public function getTranslation(): ?self
  213.     {
  214.         return $this->translation;
  215.     }
  216.     public function setTranslation(?self $translation): static
  217.     {
  218.         $this->translation $translation;
  219.         return $this;
  220.     }
  221.     /**
  222.      * @return Collection<int, self>
  223.      */
  224.     public function getTranslations(): Collection
  225.     {
  226.         return $this->translations;
  227.     }
  228.     public function addTranslation(self $translation): static
  229.     {
  230.         if (!$this->translations->contains($translation)) {
  231.             $this->translations->add($translation);
  232.             $translation->setTranslation($this);
  233.         }
  234.         return $this;
  235.     }
  236.     public function removeTranslation(self $translation): static
  237.     {
  238.         if ($this->translations->removeElement($translation)) {
  239.             // set the owning side to null (unless already changed)
  240.             if ($translation->getTranslation() === $this) {
  241.                 $translation->setTranslation(null);
  242.             }
  243.         }
  244.         return $this;
  245.     }
  246. }