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 extends AbstractCategory
  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="NONE")
  33.      */
  34.     protected $id;
  35.     /**
  36.      * @var bool
  37.      *
  38.      * @ORM\Column(type="boolean")
  39.      */
  40.     protected $active;
  41.     /**
  42.      * @var CategoryLang[]|ArrayCollection
  43.      *
  44.      * @ORM\OneToMany(targetEntity="CategoryLang", mappedBy="category", indexBy="language.name")
  45.      */
  46.     protected $langs;
  47.     public function __construct()
  48.     {
  49.         parent::__construct();
  50.     }
  51.     /**
  52.      * @return int
  53.      */
  54.     public function getId()
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function setId(int $id): self
  59.     {
  60.         $this->id $id;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return bool
  65.      */
  66.     public function isActive(): bool
  67.     {
  68.         return $this->active;
  69.     }
  70.     /**
  71.      * @param bool $active
  72.      */
  73.     public function setActive(bool $active): void
  74.     {
  75.         $this->active $active;
  76.     }
  77.     /**
  78.      * @return CategoryLang[]|ArrayCollection
  79.      */
  80.     public function getLangs()
  81.     {
  82.         return $this->langs;
  83.     }
  84.     /**
  85.      * @param CategoryLang[]|ArrayCollection $langs
  86.      *
  87.      * @return Category
  88.      */
  89.     public function setLangs($langs)
  90.     {
  91.         $this->langs $langs;
  92.         return $this;
  93.     }
  94.     public function getName(string $isoCode 'es')
  95.     {
  96.         foreach ($this->getLangs() as $categoryLang) {
  97.             if ($categoryLang->getLanguage()->getIsoCode() === $isoCode) {
  98.                 return $categoryLang->getName();
  99.             }
  100.         }
  101.         return '';
  102.     }
  103.     public function setParent(Category $parent): Category
  104.     {
  105.         $this->parent $parent;
  106.         return $this;
  107.     }
  108.     public function getParent(): CategoryInterface
  109.     {
  110.         return $this->parent;
  111.     }
  112. }