src/Entity/System/Category.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * Category
  7.  *
  8.  * @ORM\Table(name="ps_category")
  9.  *
  10.  * @ORM\Entity(repositoryClass="App\Repository\System\CategoryRepository")
  11.  */
  12. class Category
  13. {
  14.     public const FULL_CATALOGUE_CATEGORY_ID 2202;
  15.     public const FANCY_DRESS_CATEGORY_ID 2488;
  16.     public const ORIGINAL_GIFTS_CATEGORY_ID 2662;
  17.     public const TELESHOPPING_CATEGORY_ID 2672;
  18.     public const OFFERS_CATEGORY_ID 2678;
  19.     public const VALENTINE_CATEGORY_ID 3150;
  20.     public const OUTLET_CATEGORY_ID 2678;
  21.     public const HOME_GARDEN_CATEGORY_ID 2399;
  22.     public const OPENBOX_CATEGORY_ID 3045;
  23.     public const ROOT_ID 1;
  24.     public const HOME_ID 2;
  25.     /**
  26.      * @var int
  27.      *
  28.      * @ORM\Column(name="id_category", type="integer")
  29.      *
  30.      * @ORM\Id
  31.      *
  32.      * @ORM\GeneratedValue(strategy="AUTO")
  33.      */
  34.     private $id;
  35.     /**
  36.      * @var bool
  37.      *
  38.      * @ORM\Column(type="boolean")
  39.      */
  40.     private $active;
  41.     /**
  42.      * @var CategoryLang[]|ArrayCollection
  43.      *
  44.      * @ORM\OneToMany(targetEntity="CategoryLang", mappedBy="category", indexBy="language.name")
  45.      */
  46.     private $langs;
  47.     public function __construct()
  48.     {
  49.         $this->langs = new ArrayCollection();
  50.     }
  51.     /**
  52.      * @return int
  53.      */
  54.     public function getId()
  55.     {
  56.         return $this->id;
  57.     }
  58.     /**
  59.      * @return bool
  60.      */
  61.     public function isActive(): bool
  62.     {
  63.         return $this->active;
  64.     }
  65.     /**
  66.      * @param bool $active
  67.      */
  68.     public function setActive(bool $active): void
  69.     {
  70.         $this->active $active;
  71.     }
  72.     /**
  73.      * @return CategoryLang[]|ArrayCollection
  74.      */
  75.     public function getLangs()
  76.     {
  77.         return $this->langs;
  78.     }
  79.     /**
  80.      * @param CategoryLang[]|ArrayCollection $langs
  81.      *
  82.      * @return Category
  83.      */
  84.     public function setLangs($langs)
  85.     {
  86.         $this->langs $langs;
  87.         return $this;
  88.     }
  89.     public function getName(string $isoCode 'es')
  90.     {
  91.         foreach ($this->getLangs() as $categoryLang) {
  92.             if ($categoryLang->getLanguage()->getIsoCode() === $isoCode) {
  93.                 return $categoryLang->getName();
  94.             }
  95.         }
  96.         return '';
  97.     }
  98. }