src/Infrastructure/Doctrine/Entity/DoctrineUniverse.php line 26

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Infrastructure\Doctrine\Entity;
  4. use App\Domain\Common\Entity\IzOrderProductDivision;
  5. use App\Domain\Common\Entity\IzOrderProductRange;
  6. use App\Domain\Common\Entity\Universe;
  7. use App\Infrastructure\Doctrine\Entity\Traits\IdableTrait;
  8. use App\Infrastructure\Doctrine\Entity\Traits\SluggableTrait;
  9. use App\Infrastructure\Doctrine\Entity\Traits\TimestampableTrait;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Gedmo\Mapping\Annotation as Gedmo;
  14. use Symfony\Component\HttpFoundation\File\File;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  17. /**
  18.  * @ORM\Entity(repositoryClass="App\Infrastructure\Doctrine\Repository\DoctrineUniverseRepository")
  19.  *
  20.  * @Vich\Uploadable
  21.  */
  22. class DoctrineUniverse implements Universe
  23. {
  24.     use IdableTrait;
  25.     use SluggableTrait;
  26.     use TimestampableTrait;
  27.     /**
  28.      * @Gedmo\SortablePosition
  29.      * @ORM\Column(type="integer")
  30.      *
  31.      * @Assert\GreaterThanOrEqual(value="1")
  32.      * @Assert\LessThanOrEqual(value="5")
  33.      */
  34.     private int $position = -1;
  35.     /**
  36.      * @Vich\UploadableField(mapping="universes", fileNameProperty="desktopPicture")
  37.      */
  38.     private ?File $desktopPictureFile null;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     private ?string $desktopPicture null;
  43.     /**
  44.      * @Vich\UploadableField(mapping="universes", fileNameProperty="mobilePicture")
  45.      */
  46.     private ?File $mobilePictureFile null;
  47.     /**
  48.      * @ORM\Column(type="string", length=255, nullable=true)
  49.      */
  50.     private ?string $mobilePicture null;
  51.     /**
  52.      * @var Collection<int, IzOrderProductDivision>
  53.      *
  54.      * @ORM\ManyToMany(targetEntity="App\Infrastructure\Doctrine\Entity\DoctrineIzOrderProductDivision")
  55.      * @ORM\JoinTable(name="x_universe_division",
  56.      *     joinColumns={@ORM\JoinColumn(name="universe_id", referencedColumnName="id", nullable=false)},
  57.      *     inverseJoinColumns={@ORM\JoinColumn(name="division_id", referencedColumnName="code_division", nullable=false)}
  58.      * )
  59.      */
  60.     private iterable $divisions;
  61.     /**
  62.      * @var Collection<int, IzOrderProductRange>
  63.      *
  64.      * @ORM\ManyToMany(targetEntity="App\Infrastructure\Doctrine\Entity\DoctrineIzOrderProductRange")
  65.      * @ORM\JoinTable(name="x_universe_range",
  66.      *     joinColumns={@ORM\JoinColumn(name="universe_id", referencedColumnName="id", nullable=false)},
  67.      *     inverseJoinColumns={@ORM\JoinColumn(name="range_id", referencedColumnName="code_gamme", nullable=false)}
  68.      * )
  69.      */
  70.     private iterable $ranges;
  71.     public function __construct()
  72.     {
  73.         $this->divisions = new ArrayCollection();
  74.         $this->ranges = new ArrayCollection();
  75.     }
  76.     public function getPosition(): int
  77.     {
  78.         return $this->position;
  79.     }
  80.     public function setPosition(int $position): void
  81.     {
  82.         $this->position $position;
  83.     }
  84.     public function getDesktopPictureFile(): ?File
  85.     {
  86.         return $this->desktopPictureFile;
  87.     }
  88.     public function setDesktopPictureFile(?File $desktopPictureFile): void
  89.     {
  90.         $this->desktopPictureFile $desktopPictureFile;
  91.         if (null !== $desktopPictureFile) {
  92.             $this->setUpdatedAt(new \DateTimeImmutable());
  93.         }
  94.     }
  95.     public function getDesktopPicture(): ?string
  96.     {
  97.         return $this->desktopPicture;
  98.     }
  99.     public function setDesktopPicture(?string $desktopPicture): void
  100.     {
  101.         $this->desktopPicture $desktopPicture;
  102.     }
  103.     public function getMobilePictureFile(): ?File
  104.     {
  105.         return $this->mobilePictureFile;
  106.     }
  107.     public function setMobilePictureFile(?File $mobilePictureFile): void
  108.     {
  109.         $this->mobilePictureFile $mobilePictureFile;
  110.         if (null !== $mobilePictureFile) {
  111.             $this->setUpdatedAt(new \DateTimeImmutable());
  112.         }
  113.     }
  114.     public function getMobilePicture(): ?string
  115.     {
  116.         return $this->mobilePicture;
  117.     }
  118.     public function setMobilePicture(?string $mobilePicture): void
  119.     {
  120.         $this->mobilePicture $mobilePicture;
  121.     }
  122.     /**
  123.      * {@inheritDoc}
  124.      */
  125.     public function getDivisions(): iterable
  126.     {
  127.         return $this->divisions;
  128.     }
  129.     public function addDivision(IzOrderProductDivision $division): void
  130.     {
  131.         if (!$this->divisions->contains($division)) {
  132.             $this->divisions[] = $division;
  133.         }
  134.     }
  135.     public function removeDivision(IzOrderProductDivision $division): void
  136.     {
  137.         $this->divisions->removeElement($division);
  138.     }
  139.     /**
  140.      * {@inheritDoc}
  141.      */
  142.     public function getRanges(): iterable
  143.     {
  144.         return $this->ranges;
  145.     }
  146.     public function addRange(IzOrderProductRange $range): void
  147.     {
  148.         if (!$this->ranges->contains($range)) {
  149.             $this->ranges[] = $range;
  150.         }
  151.     }
  152.     public function removeRange(IzOrderProductRange $range): void
  153.     {
  154.         $this->ranges->removeElement($range);
  155.     }
  156. }