<?php
declare(strict_types=1);
namespace App\Infrastructure\Doctrine\Entity;
use App\Domain\Common\Entity\IzOrderProductDivision;
use App\Domain\Common\Entity\IzOrderProductRange;
use App\Domain\Common\Entity\Universe;
use App\Infrastructure\Doctrine\Entity\Traits\IdableTrait;
use App\Infrastructure\Doctrine\Entity\Traits\SluggableTrait;
use App\Infrastructure\Doctrine\Entity\Traits\TimestampableTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass="App\Infrastructure\Doctrine\Repository\DoctrineUniverseRepository")
*
* @Vich\Uploadable
*/
class DoctrineUniverse implements Universe
{
use IdableTrait;
use SluggableTrait;
use TimestampableTrait;
/**
* @Gedmo\SortablePosition
* @ORM\Column(type="integer")
*
* @Assert\GreaterThanOrEqual(value="1")
* @Assert\LessThanOrEqual(value="5")
*/
private int $position = -1;
/**
* @Vich\UploadableField(mapping="universes", fileNameProperty="desktopPicture")
*/
private ?File $desktopPictureFile = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $desktopPicture = null;
/**
* @Vich\UploadableField(mapping="universes", fileNameProperty="mobilePicture")
*/
private ?File $mobilePictureFile = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $mobilePicture = null;
/**
* @var Collection<int, IzOrderProductDivision>
*
* @ORM\ManyToMany(targetEntity="App\Infrastructure\Doctrine\Entity\DoctrineIzOrderProductDivision")
* @ORM\JoinTable(name="x_universe_division",
* joinColumns={@ORM\JoinColumn(name="universe_id", referencedColumnName="id", nullable=false)},
* inverseJoinColumns={@ORM\JoinColumn(name="division_id", referencedColumnName="code_division", nullable=false)}
* )
*/
private iterable $divisions;
/**
* @var Collection<int, IzOrderProductRange>
*
* @ORM\ManyToMany(targetEntity="App\Infrastructure\Doctrine\Entity\DoctrineIzOrderProductRange")
* @ORM\JoinTable(name="x_universe_range",
* joinColumns={@ORM\JoinColumn(name="universe_id", referencedColumnName="id", nullable=false)},
* inverseJoinColumns={@ORM\JoinColumn(name="range_id", referencedColumnName="code_gamme", nullable=false)}
* )
*/
private iterable $ranges;
public function __construct()
{
$this->divisions = new ArrayCollection();
$this->ranges = new ArrayCollection();
}
public function getPosition(): int
{
return $this->position;
}
public function setPosition(int $position): void
{
$this->position = $position;
}
public function getDesktopPictureFile(): ?File
{
return $this->desktopPictureFile;
}
public function setDesktopPictureFile(?File $desktopPictureFile): void
{
$this->desktopPictureFile = $desktopPictureFile;
if (null !== $desktopPictureFile) {
$this->setUpdatedAt(new \DateTimeImmutable());
}
}
public function getDesktopPicture(): ?string
{
return $this->desktopPicture;
}
public function setDesktopPicture(?string $desktopPicture): void
{
$this->desktopPicture = $desktopPicture;
}
public function getMobilePictureFile(): ?File
{
return $this->mobilePictureFile;
}
public function setMobilePictureFile(?File $mobilePictureFile): void
{
$this->mobilePictureFile = $mobilePictureFile;
if (null !== $mobilePictureFile) {
$this->setUpdatedAt(new \DateTimeImmutable());
}
}
public function getMobilePicture(): ?string
{
return $this->mobilePicture;
}
public function setMobilePicture(?string $mobilePicture): void
{
$this->mobilePicture = $mobilePicture;
}
/**
* {@inheritDoc}
*/
public function getDivisions(): iterable
{
return $this->divisions;
}
public function addDivision(IzOrderProductDivision $division): void
{
if (!$this->divisions->contains($division)) {
$this->divisions[] = $division;
}
}
public function removeDivision(IzOrderProductDivision $division): void
{
$this->divisions->removeElement($division);
}
/**
* {@inheritDoc}
*/
public function getRanges(): iterable
{
return $this->ranges;
}
public function addRange(IzOrderProductRange $range): void
{
if (!$this->ranges->contains($range)) {
$this->ranges[] = $range;
}
}
public function removeRange(IzOrderProductRange $range): void
{
$this->ranges->removeElement($range);
}
}