<?php
namespace App\Entity\Tires;
use App\Annotation\SiteAware;
use App\Entity\AbstractBase;
use App\Entity\Interfaces\ImageInterface;
use App\Entity\Interfaces\PublishedInterface;
use App\Entity\Interfaces\SiteInterface;
use App\Entity\Interfaces\SlugInterface;
use App\Entity\Traits\DescriptionTrait;
use App\Entity\Traits\HasImageTrait;
use App\Entity\Traits\NameTrait;
use App\Entity\Traits\PublishedTrait;
use App\Entity\Traits\SiteTrait;
use App\Entity\Traits\SlugTrait;
use App\Enum\TireNoiseClassEnum;
use App\Enum\TireSeasonEnum;
use App\Repository\Tires\TireRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Table(name="vulco_tire", indexes={@ORM\Index(name="tire_site_idx", columns={"site"}), @ORM\Index(name="tire_slug_idx", columns={"slug"})})
* @ORM\Entity(repositoryClass=TireRepository::class)
* @Gedmo\SoftDeleteable(fieldName="removedAt", timeAware=false)
* @SiteAware(siteFieldName="site")
* @Vich\Uploadable
* @UniqueEntity("slug")
*/
class Tire extends AbstractBase implements SiteInterface, SlugInterface, PublishedInterface, ImageInterface
{
use DescriptionTrait;
use NameTrait;
use PublishedTrait;
use SiteTrait;
use SlugTrait;
use HasImageTrait;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Tires\TireBrand", cascade={"persist"})
* @ORM\JoinColumn(name="tire_brand_id", referencedColumnName="id")
*/
private TireBrand $tireBrand;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Tires\TireSize", cascade={"persist"})
* @ORM\JoinColumn(name="tire_size_id", referencedColumnName="id")
*/
private TireSize $tireSize;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $name;
/**
* @ORM\Column(type="string", length=255, nullable=false)
* @Gedmo\Slug(fields={"name"}, unique=true, updatable=true, handlers={
* @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\RelativeSlugHandler", options={
* @Gedmo\SlugHandlerOption(name="relationField", value="tireBrand"),
* @Gedmo\SlugHandlerOption(name="relationSlugField", value="name"),
* @Gedmo\SlugHandlerOption(name="separator", value="-"),
* @Gedmo\SlugHandlerOption(name="urilize", value=true)
* })
* })
* https://github.com/doctrine-extensions/DoctrineExtensions/blob/main/doc/sluggable.md#slug-handlers
*/
private string $slug;
/**
* @ORM\Column(type="text", length=10000, nullable=true)
*/
private ?string $description = null;
/**
* @Vich\UploadableField(mapping="tire_image", fileNameProperty="imageName")
*/
private ?File $image = null;
/**
* @ORM\Column(type="bigint", nullable=true)
*/
private ?int $ean;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $sapCode;
/**
* @ORM\Column(type="boolean", nullable=false)
*/
private bool $runflat;
/**
* @ORM\Column(type="boolean", nullable=false)
*/
private bool $reinforced;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $noise;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $noiseClass;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $wetClass;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $season;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $rollingResistance;
/**
* @ORM\Column(type="boolean", nullable=false)
*/
private bool $markMS;
/**
* @ORM\Column(name="mark3pmsf", type="boolean", nullable=false)
*/
private bool $mark3PMSF;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $euDirectiveNumber;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $goodyearLabelUrl;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $eprelLabelUrl;
public function __construct()
{
}
public function getTireBrand(): TireBrand
{
return $this->tireBrand;
}
public function setTireBrand(TireBrand $tireBrand = null): self
{
$this->tireBrand = $tireBrand;
return $this;
}
public function getBrand(): TireBrand
{
return $this->getTireBrand();
}
public function setBrand(TireBrand $tireBrand = null): self
{
return $this->setTireBrand($tireBrand);
}
public function getTireSize(): TireSize
{
return $this->tireSize;
}
public function setTireSize(TireSize $tireSize = null): self
{
$this->tireSize = $tireSize;
return $this;
}
public function getSize(): TireSize
{
return $this->getTireSize();
}
public function setSize(TireSize $tireSize = null): self
{
return $this->setTireSize($tireSize);
}
public function getEan(): ?int
{
return $this->ean;
}
public function setEan(?int $ean): self
{
$this->ean = $ean;
return $this;
}
public function getSapCode(): ?string
{
return $this->sapCode;
}
public function setSapCode(?string $sapCode): self
{
$this->sapCode = $sapCode;
return $this;
}
public function getRunflat(): bool
{
return $this->runflat;
}
public function setRunflat(bool $runflat): self
{
$this->runflat = $runflat;
return $this;
}
public function isReinforced(): bool
{
return $this->reinforced;
}
public function getReinforced(): bool
{
return $this->isReinforced();
}
public function setReinforced(bool $reinforced): self
{
$this->reinforced = $reinforced;
return $this;
}
public function getNoise(): ?string
{
return $this->noise;
}
public function setNoise(?string $noise): self
{
$this->noise = $noise;
return $this;
}
public function getNoiseClass(): ?string
{
return $this->noiseClass;
}
public function setNoiseClass(?string $noiseClass): self
{
$this->noiseClass = $noiseClass;
return $this;
}
public function getWetClass(): ?string
{
return $this->wetClass;
}
public function setWetClass(?string $wetClass): self
{
$this->wetClass = $wetClass;
return $this;
}
public function getSeason(): string
{
return $this->season;
}
public function setSeason(string $season): self
{
$this->season = $season;
return $this;
}
public function getRollingResistance(): ?string
{
return $this->rollingResistance;
}
public function setRollingResistance(?string $rollingResistance): self
{
$this->rollingResistance = $rollingResistance;
return $this;
}
public function isMarkMS(): bool
{
return $this->markMS;
}
public function getMarkMS(): bool
{
return $this->isMarkMS();
}
public function setMarkMS(bool $markMS): self
{
$this->markMS = $markMS;
return $this;
}
public function isMark3PMSF(): bool
{
return $this->mark3PMSF;
}
public function getMark3PMSF(): bool
{
return $this->isMark3PMSF();
}
public function setMark3PMSF(bool $mark3PMSF): self
{
$this->mark3PMSF = $mark3PMSF;
return $this;
}
public function getEuDirectiveNumber(): ?string
{
return $this->euDirectiveNumber;
}
public function setEuDirectiveNumber(?string $euDirectiveNumber): self
{
$this->euDirectiveNumber = $euDirectiveNumber;
return $this;
}
public function getGoodyearLabelUrl(): ?string
{
return $this->goodyearLabelUrl;
}
public function setGoodyearLabelUrl(?string $goodyearLabelUrl): self
{
$this->goodyearLabelUrl = $goodyearLabelUrl;
return $this;
}
public function getEprelLabelUrl(): ?string
{
return $this->eprelLabelUrl;
}
public function setEprelLabelUrl(?string $eprelLabelUrl): self
{
$this->eprelLabelUrl = $eprelLabelUrl;
return $this;
}
public function getSeasonTranslation(): string
{
if (array_key_exists($this->getSeason(), TireSeasonEnum::getTranslations())) {
return TireSeasonEnum::getTranslations()[$this->getSeason()];
}
return 'n/a';
}
public function getNoiseClassTranslation(): string
{
if (array_key_exists($this->getNoiseClass(), TireNoiseClassEnum::getTranslations())) {
return TireNoiseClassEnum::getTranslations()[$this->getNoiseClass()];
}
return 'n/a';
}
public function isSummerType(): bool
{
return TireSeasonEnum::SUMMER == $this->season;
}
public function isWinterType(): bool
{
return TireSeasonEnum::WINTER == $this->season;
}
public function isAllSeasonType(): bool
{
return TireSeasonEnum::ALL_SEASON == $this->season;
}
public function __toString(): string
{
return $this->getBrand()->getName().' '.$this->getName();
}
}