src/Entity/System/Feature.php line 18

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\System;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity()
  9.  *
  10.  * @ORM\Table(name="ps_feature")
  11.  *
  12.  * @ORM\Entity(repositoryClass="App\Repository\System\FeatureRepository")
  13.  */
  14. class Feature
  15. {
  16.     /**
  17.      * @var int
  18.      *
  19.      * @ORM\Id
  20.      *
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      *
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @var string
  28.      *
  29.      * @ORM\Column(type="string", length=30)
  30.      */
  31.     private $reference;
  32.     /**
  33.      * @var \DateTime
  34.      *
  35.      * @ORM\Column(type="datetime")
  36.      */
  37.     private $dateAdd;
  38.     /**
  39.      * @var bool
  40.      *
  41.      * @ORM\Column(type="boolean")
  42.      */
  43.     private $active;
  44.     /**
  45.      * @var FeatureLang[]|Collection<int, FeatureLang>
  46.      *
  47.      * @ORM\OneToMany(targetEntity="FeatureLang", mappedBy="feature")
  48.      */
  49.     private $featureLangs;
  50.     /**
  51.      * @var ArrayCollection<int, FeatureProduct>|FeatureProduct[]
  52.      *
  53.      * @ORM\OneToMany(targetEntity="App\Entity\System\FeatureProduct", mappedBy="feature")
  54.      */
  55.     private $featureProducts;
  56.     public function __construct()
  57.     {
  58.         $this->featureLangs = new ArrayCollection();
  59.         $this->featureProducts = new ArrayCollection();
  60.     }
  61.     public function getId(): int
  62.     {
  63.         return $this->id;
  64.     }
  65.     public function getReference(): string
  66.     {
  67.         return $this->reference;
  68.     }
  69.     public function setReference(string $reference): Feature
  70.     {
  71.         $this->reference $reference;
  72.         return $this;
  73.     }
  74.     public function getDateAdd(): \DateTime
  75.     {
  76.         return $this->dateAdd;
  77.     }
  78.     public function setDateAdd(\DateTime $dateAdd): Feature
  79.     {
  80.         $this->dateAdd $dateAdd;
  81.         return $this;
  82.     }
  83.     public function isActive(): bool
  84.     {
  85.         return $this->active;
  86.     }
  87.     public function setActive(bool $active): Feature
  88.     {
  89.         $this->active $active;
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return FeatureLang[]|Collection<int, FeatureLang>
  94.      */
  95.     public function getFeatureLangs()
  96.     {
  97.         return $this->featureLangs;
  98.     }
  99.     /**
  100.      * @param Collection<int, FeatureLang>|FeatureLang[] $featureLangs
  101.      */
  102.     public function setFeatureLangs($featureLangs): Feature
  103.     {
  104.         $this->featureLangs $featureLangs;
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return FeatureProduct[]|ArrayCollection<int, FeatureProduct>
  109.      */
  110.     public function getFeatureProducts()
  111.     {
  112.         return $this->featureProducts;
  113.     }
  114.     /**
  115.      * @param FeatureProduct[]|ArrayCollection<int, FeatureProduct> $featureProducts
  116.      *
  117.      * @return Feature
  118.      */
  119.     public function setFeatureProducts($featureProducts)
  120.     {
  121.         $this->featureProducts $featureProducts;
  122.         return $this;
  123.     }
  124.     /**
  125.      * @return array<string, FeatureLang>
  126.      */
  127.     public function getTranslationsIndexedByIsoCode(): array
  128.     {
  129.         $translations = [];
  130.         foreach ($this->featureLangs as $translation) {
  131.             $isoCode strtolower($translation->getLanguage()->getIsoCode());
  132.             $translations[$isoCode] = $translation;
  133.         }
  134.         return $translations;
  135.     }
  136. }