src/Entity/Tires/Tire.php line 34

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Tires;
  3. use App\Annotation\SiteAware;
  4. use App\Entity\AbstractBase;
  5. use App\Entity\Interfaces\ImageInterface;
  6. use App\Entity\Interfaces\PublishedInterface;
  7. use App\Entity\Interfaces\SiteInterface;
  8. use App\Entity\Interfaces\SlugInterface;
  9. use App\Entity\Traits\DescriptionTrait;
  10. use App\Entity\Traits\HasImageTrait;
  11. use App\Entity\Traits\NameTrait;
  12. use App\Entity\Traits\PublishedTrait;
  13. use App\Entity\Traits\SiteTrait;
  14. use App\Entity\Traits\SlugTrait;
  15. use App\Enum\TireNoiseClassEnum;
  16. use App\Enum\TireSeasonEnum;
  17. use App\Repository\Tires\TireRepository;
  18. use Doctrine\ORM\Mapping as ORM;
  19. use Gedmo\Mapping\Annotation as Gedmo;
  20. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  21. use Symfony\Component\HttpFoundation\File\File;
  22. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  23. /**
  24.  * @ORM\Table(name="vulco_tire", indexes={@ORM\Index(name="tire_site_idx", columns={"site"}), @ORM\Index(name="tire_slug_idx", columns={"slug"})})
  25.  * @ORM\Entity(repositoryClass=TireRepository::class)
  26.  * @Gedmo\SoftDeleteable(fieldName="removedAt", timeAware=false)
  27.  * @SiteAware(siteFieldName="site")
  28.  * @Vich\Uploadable
  29.  * @UniqueEntity("slug")
  30.  */
  31. class Tire extends AbstractBase implements SiteInterfaceSlugInterfacePublishedInterfaceImageInterface
  32. {
  33.     use DescriptionTrait;
  34.     use NameTrait;
  35.     use PublishedTrait;
  36.     use SiteTrait;
  37.     use SlugTrait;
  38.     use HasImageTrait;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity="App\Entity\Tires\TireBrand", cascade={"persist"})
  41.      * @ORM\JoinColumn(name="tire_brand_id", referencedColumnName="id")
  42.      */
  43.     private TireBrand $tireBrand;
  44.     /**
  45.      * @ORM\ManyToOne(targetEntity="App\Entity\Tires\TireSize", cascade={"persist"})
  46.      * @ORM\JoinColumn(name="tire_size_id", referencedColumnName="id")
  47.      */
  48.     private TireSize $tireSize;
  49.     /**
  50.      * @ORM\Column(type="string", length=255, nullable=false)
  51.      */
  52.     private string $name;
  53.     /**
  54.      * @ORM\Column(type="string", length=255, nullable=false)
  55.      * @Gedmo\Slug(fields={"name"}, unique=true, updatable=true, handlers={
  56.      *      @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\RelativeSlugHandler", options={
  57.      *          @Gedmo\SlugHandlerOption(name="relationField", value="tireBrand"),
  58.      *          @Gedmo\SlugHandlerOption(name="relationSlugField", value="name"),
  59.      *          @Gedmo\SlugHandlerOption(name="separator", value="-"),
  60.      *          @Gedmo\SlugHandlerOption(name="urilize", value=true)
  61.      *      })
  62.      * })
  63.      * https://github.com/doctrine-extensions/DoctrineExtensions/blob/main/doc/sluggable.md#slug-handlers
  64.      */
  65.     private string $slug;
  66.     /**
  67.      * @ORM\Column(type="text", length=10000, nullable=true)
  68.      */
  69.     private ?string $description null;
  70.     /**
  71.      * @Vich\UploadableField(mapping="tire_image", fileNameProperty="imageName")
  72.      */
  73.     private ?File $image null;
  74.     /**
  75.      * @ORM\Column(type="bigint", nullable=true)
  76.      */
  77.     private ?int $ean;
  78.     /**
  79.      * @ORM\Column(type="string", length=255, nullable=true)
  80.      */
  81.     private ?string $sapCode;
  82.     /**
  83.      * @ORM\Column(type="boolean", nullable=false)
  84.      */
  85.     private bool $runflat;
  86.     /**
  87.      * @ORM\Column(type="boolean", nullable=false)
  88.      */
  89.     private bool $reinforced;
  90.     /**
  91.      * @ORM\Column(type="string", length=255, nullable=true)
  92.      */
  93.     private ?string $noise;
  94.     /**
  95.      * @ORM\Column(type="string", length=255, nullable=true)
  96.      */
  97.     private ?string $noiseClass;
  98.     /**
  99.      * @ORM\Column(type="string", length=255, nullable=true)
  100.      */
  101.     private ?string $wetClass;
  102.     /**
  103.      * @ORM\Column(type="string", length=255, nullable=false)
  104.      */
  105.     private string $season;
  106.     /**
  107.      * @ORM\Column(type="string", length=255, nullable=true)
  108.      */
  109.     private ?string $rollingResistance;
  110.     /**
  111.      * @ORM\Column(type="boolean", nullable=false)
  112.      */
  113.     private bool $markMS;
  114.     /**
  115.      * @ORM\Column(name="mark3pmsf", type="boolean", nullable=false)
  116.      */
  117.     private bool $mark3PMSF;
  118.     /**
  119.      * @ORM\Column(type="string", length=255, nullable=true)
  120.      */
  121.     private ?string $euDirectiveNumber;
  122.     /**
  123.      * @ORM\Column(type="string", length=255, nullable=true)
  124.      */
  125.     private ?string $goodyearLabelUrl;
  126.     /**
  127.      * @ORM\Column(type="string", length=255, nullable=true)
  128.      */
  129.     private ?string $eprelLabelUrl;
  130.     public function __construct()
  131.     {
  132.     }
  133.     public function getTireBrand(): TireBrand
  134.     {
  135.         return $this->tireBrand;
  136.     }
  137.     public function setTireBrand(TireBrand $tireBrand null): self
  138.     {
  139.         $this->tireBrand $tireBrand;
  140.         return $this;
  141.     }
  142.     public function getBrand(): TireBrand
  143.     {
  144.         return $this->getTireBrand();
  145.     }
  146.     public function setBrand(TireBrand $tireBrand null): self
  147.     {
  148.         return $this->setTireBrand($tireBrand);
  149.     }
  150.     public function getTireSize(): TireSize
  151.     {
  152.         return $this->tireSize;
  153.     }
  154.     public function setTireSize(TireSize $tireSize null): self
  155.     {
  156.         $this->tireSize $tireSize;
  157.         return $this;
  158.     }
  159.     public function getSize(): TireSize
  160.     {
  161.         return $this->getTireSize();
  162.     }
  163.     public function setSize(TireSize $tireSize null): self
  164.     {
  165.         return $this->setTireSize($tireSize);
  166.     }
  167.     public function getEan(): ?int
  168.     {
  169.         return $this->ean;
  170.     }
  171.     public function setEan(?int $ean): self
  172.     {
  173.         $this->ean $ean;
  174.         return $this;
  175.     }
  176.     public function getSapCode(): ?string
  177.     {
  178.         return $this->sapCode;
  179.     }
  180.     public function setSapCode(?string $sapCode): self
  181.     {
  182.         $this->sapCode $sapCode;
  183.         return $this;
  184.     }
  185.     public function getRunflat(): bool
  186.     {
  187.         return $this->runflat;
  188.     }
  189.     public function setRunflat(bool $runflat): self
  190.     {
  191.         $this->runflat $runflat;
  192.         return $this;
  193.     }
  194.     public function isReinforced(): bool
  195.     {
  196.         return $this->reinforced;
  197.     }
  198.     public function getReinforced(): bool
  199.     {
  200.         return $this->isReinforced();
  201.     }
  202.     public function setReinforced(bool $reinforced): self
  203.     {
  204.         $this->reinforced $reinforced;
  205.         return $this;
  206.     }
  207.     public function getNoise(): ?string
  208.     {
  209.         return $this->noise;
  210.     }
  211.     public function setNoise(?string $noise): self
  212.     {
  213.         $this->noise $noise;
  214.         return $this;
  215.     }
  216.     public function getNoiseClass(): ?string
  217.     {
  218.         return $this->noiseClass;
  219.     }
  220.     public function setNoiseClass(?string $noiseClass): self
  221.     {
  222.         $this->noiseClass $noiseClass;
  223.         return $this;
  224.     }
  225.     public function getWetClass(): ?string
  226.     {
  227.         return $this->wetClass;
  228.     }
  229.     public function setWetClass(?string $wetClass): self
  230.     {
  231.         $this->wetClass $wetClass;
  232.         return $this;
  233.     }
  234.     public function getSeason(): string
  235.     {
  236.         return $this->season;
  237.     }
  238.     public function setSeason(string $season): self
  239.     {
  240.         $this->season $season;
  241.         return $this;
  242.     }
  243.     public function getRollingResistance(): ?string
  244.     {
  245.         return $this->rollingResistance;
  246.     }
  247.     public function setRollingResistance(?string $rollingResistance): self
  248.     {
  249.         $this->rollingResistance $rollingResistance;
  250.         return $this;
  251.     }
  252.     public function isMarkMS(): bool
  253.     {
  254.         return $this->markMS;
  255.     }
  256.     public function getMarkMS(): bool
  257.     {
  258.         return $this->isMarkMS();
  259.     }
  260.     public function setMarkMS(bool $markMS): self
  261.     {
  262.         $this->markMS $markMS;
  263.         return $this;
  264.     }
  265.     public function isMark3PMSF(): bool
  266.     {
  267.         return $this->mark3PMSF;
  268.     }
  269.     public function getMark3PMSF(): bool
  270.     {
  271.         return $this->isMark3PMSF();
  272.     }
  273.     public function setMark3PMSF(bool $mark3PMSF): self
  274.     {
  275.         $this->mark3PMSF $mark3PMSF;
  276.         return $this;
  277.     }
  278.     public function getEuDirectiveNumber(): ?string
  279.     {
  280.         return $this->euDirectiveNumber;
  281.     }
  282.     public function setEuDirectiveNumber(?string $euDirectiveNumber): self
  283.     {
  284.         $this->euDirectiveNumber $euDirectiveNumber;
  285.         return $this;
  286.     }
  287.     public function getGoodyearLabelUrl(): ?string
  288.     {
  289.         return $this->goodyearLabelUrl;
  290.     }
  291.     public function setGoodyearLabelUrl(?string $goodyearLabelUrl): self
  292.     {
  293.         $this->goodyearLabelUrl $goodyearLabelUrl;
  294.         return $this;
  295.     }
  296.     public function getEprelLabelUrl(): ?string
  297.     {
  298.         return $this->eprelLabelUrl;
  299.     }
  300.     public function setEprelLabelUrl(?string $eprelLabelUrl): self
  301.     {
  302.         $this->eprelLabelUrl $eprelLabelUrl;
  303.         return $this;
  304.     }
  305.     public function getSeasonTranslation(): string
  306.     {
  307.         if (array_key_exists($this->getSeason(), TireSeasonEnum::getTranslations())) {
  308.             return TireSeasonEnum::getTranslations()[$this->getSeason()];
  309.         }
  310.         return 'n/a';
  311.     }
  312.     public function getNoiseClassTranslation(): string
  313.     {
  314.         if (array_key_exists($this->getNoiseClass(), TireNoiseClassEnum::getTranslations())) {
  315.             return TireNoiseClassEnum::getTranslations()[$this->getNoiseClass()];
  316.         }
  317.         return 'n/a';
  318.     }
  319.     public function isSummerType(): bool
  320.     {
  321.         return TireSeasonEnum::SUMMER == $this->season;
  322.     }
  323.     public function isWinterType(): bool
  324.     {
  325.         return TireSeasonEnum::WINTER == $this->season;
  326.     }
  327.     public function isAllSeasonType(): bool
  328.     {
  329.         return TireSeasonEnum::ALL_SEASON == $this->season;
  330.     }
  331.     public function __toString(): string
  332.     {
  333.         return $this->getBrand()->getName().' '.$this->getName();
  334.     }
  335. }