<?php
namespace App\Entity\System;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Category
*
* @ORM\Table(name="ps_category")
*
* @ORM\Entity(repositoryClass="App\Repository\System\CategoryRepository")
*/
class Category
{
public const FULL_CATALOGUE_CATEGORY_ID = 2202;
public const FANCY_DRESS_CATEGORY_ID = 2488;
public const ORIGINAL_GIFTS_CATEGORY_ID = 2662;
public const TELESHOPPING_CATEGORY_ID = 2672;
public const OFFERS_CATEGORY_ID = 2678;
public const VALENTINE_CATEGORY_ID = 3150;
public const OUTLET_CATEGORY_ID = 2678;
public const HOME_GARDEN_CATEGORY_ID = 2399;
public const OPENBOX_CATEGORY_ID = 3045;
public const ROOT_ID = 1;
public const HOME_ID = 2;
/**
* @var int
*
* @ORM\Column(name="id_category", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var bool
*
* @ORM\Column(type="boolean")
*/
private $active;
/**
* @var CategoryLang[]|ArrayCollection
*
* @ORM\OneToMany(targetEntity="CategoryLang", mappedBy="category", indexBy="language.name")
*/
private $langs;
public function __construct()
{
$this->langs = new ArrayCollection();
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return bool
*/
public function isActive(): bool
{
return $this->active;
}
/**
* @param bool $active
*/
public function setActive(bool $active): void
{
$this->active = $active;
}
/**
* @return CategoryLang[]|ArrayCollection
*/
public function getLangs()
{
return $this->langs;
}
/**
* @param CategoryLang[]|ArrayCollection $langs
*
* @return Category
*/
public function setLangs($langs)
{
$this->langs = $langs;
return $this;
}
public function getName(string $isoCode = 'es')
{
foreach ($this->getLangs() as $categoryLang) {
if ($categoryLang->getLanguage()->getIsoCode() === $isoCode) {
return $categoryLang->getName();
}
}
return '';
}
}