src/Entity/Slider.php line 20

Open in your IDE?
  1. <?php
  2.     namespace App\Entity;
  3.     use App\Repository\SliderRepository;
  4.     use App\Traits\DateTrait;
  5.     use DateTimeInterface;
  6.     use Doctrine\Common\Collections\ArrayCollection;
  7.     use Doctrine\Common\Collections\Collection;
  8.     use Doctrine\ORM\Mapping as ORM;
  9.     use JMS\Serializer\Annotation as Serializer;
  10.     use JMS\Serializer\Annotation\Expose;
  11.     use JMS\Serializer\Annotation\Groups;
  12.     /**
  13.      * @ORM\Entity(repositoryClass=SliderRepository::class)
  14.      *
  15.      * @Serializer\ExclusionPolicy("ALL")
  16.      */
  17.     class Slider
  18.     {
  19.         /**
  20.          * @ORM\Id
  21.          * @ORM\GeneratedValue
  22.          * @ORM\Column(type="integer")
  23.          *
  24.          * @Expose
  25.          * @Groups({"slider"})
  26.          */
  27.         private $id;
  28.         /**
  29.          * @ORM\Column(type="string", length=255)
  30.          *
  31.          * @Expose
  32.          * @Groups({"slider"})
  33.          */
  34.         private $title;
  35.         /**
  36.          * @ORM\OneToMany(targetEntity=SliderItem::class, mappedBy="slider", cascade={"persist","remove"})
  37.          * @ORM\OrderBy({"orderItem" = "ASC"})
  38.          */
  39.         private $items;
  40.         /**
  41.          * @ORM\Column(type="datetime", nullable=true)
  42.          *
  43.          * @Expose
  44.          * @Groups({"slider"})
  45.          */
  46.         private $dateStart;
  47.         /**
  48.          * @ORM\Column(type="datetime", nullable=true)
  49.          *
  50.          * @Expose
  51.          * @Groups({"slider"})
  52.          */
  53.         private $dateEnd;
  54.         /**
  55.          * @ORM\Column(type="string", length=64)
  56.          *
  57.          * @Expose
  58.          * @Groups({"slider"})
  59.          */
  60.         private $slug;
  61.         /**
  62.          * @ORM\Column(type="string", length=255)
  63.          *
  64.          * @Expose
  65.          * @Groups({"slider"})
  66.          */
  67.         private $subdomain;
  68.         use DateTrait;
  69.         public function __construct()
  70.         {
  71.             $this->items = new ArrayCollection();
  72.         }
  73.         public function __toString()
  74.         {
  75.             return $this->title;
  76.         }
  77.         /*
  78.          * ============================================================================================
  79.          * =============================== FONCTIONS CUSTOM ===========================================
  80.          * ============================================================================================
  81.          */
  82.         public function getItemsNumber()
  83.         {
  84.             return count$this->getItems() );
  85.         }
  86.         /*
  87.          * ============================================================================================
  88.          * ============================== FIN FONCTIONS CUSTOM ========================================
  89.          * ============================================================================================
  90.          */
  91.         /**
  92.          * @return Collection|SliderItem[]
  93.          */
  94.         public function getItems(): Collection
  95.         {
  96.             return $this->items;
  97.         }
  98.         public function getId(): ?int
  99.         {
  100.             return $this->id;
  101.         }
  102.         public function getTitle(): ?string
  103.         {
  104.             return $this->title;
  105.         }
  106.         public function setTitlestring $title ): self
  107.         {
  108.             $this->title $title;
  109.             return $this;
  110.         }
  111.         public function addSliderItemSliderItem $sliderItem ): self
  112.         {
  113.             if ( !$this->items->contains$sliderItem ) ) {
  114.                 $this->items[] = $sliderItem;
  115.                 $sliderItem->setSlider$this );
  116.             }
  117.             return $this;
  118.         }
  119.         public function removeSliderItemSliderItem $sliderItem ): self
  120.         {
  121.             if ( $this->items->removeElement$sliderItem ) ) {
  122.                 // set the owning side to null (unless already changed)
  123.                 if ( $sliderItem->getSlider() === $this ) {
  124.                     $sliderItem->setSliderNULL );
  125.                 }
  126.             }
  127.             return $this;
  128.         }
  129.         public function addItemSliderItem $item ): self
  130.         {
  131.             if ( !$this->items->contains$item ) ) {
  132.                 $this->items[] = $item;
  133.                 $item->setSlider$this );
  134.             }
  135.             return $this;
  136.         }
  137.         public function removeItemSliderItem $item ): self
  138.         {
  139.             if ( $this->items->removeElement$item ) ) {
  140.                 // set the owning side to null (unless already changed)
  141.                 if ( $item->getSlider() === $this ) {
  142.                     $item->setSliderNULL );
  143.                 }
  144.             }
  145.             return $this;
  146.         }
  147.         public function getDateStart(): ?DateTimeInterface
  148.         {
  149.             return $this->dateStart;
  150.         }
  151.         public function setDateStart( ?DateTimeInterface $dateStart ): self
  152.         {
  153.             $this->dateStart $dateStart;
  154.             return $this;
  155.         }
  156.         public function getDateEnd(): ?DateTimeInterface
  157.         {
  158.             return $this->dateEnd;
  159.         }
  160.         public function setDateEnd( ?DateTimeInterface $dateEnd ): self
  161.         {
  162.             $this->dateEnd $dateEnd;
  163.             return $this;
  164.         }
  165.         public function getSlug(): ?string
  166.         {
  167.             return $this->slug;
  168.         }
  169.         public function setSlugstring $slug ): self
  170.         {
  171.             $this->slug $slug;
  172.             return $this;
  173.         }
  174.         public function getSubdomain(): ?string
  175.         {
  176.             return $this->subdomain;
  177.         }
  178.         public function setSubdomain(string $subdomain): self
  179.         {
  180.             $this->subdomain $subdomain;
  181.             return $this;
  182.         }
  183.     }