<?php
namespace App\Entity;
use App\Repository\CategorieRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Polyfill\Intl\Icu\Locale;
use App\Entity\Produit\Produit;
#[ORM\Entity(repositoryClass: CategorieRepository::class)]
class Categorie
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\Column(type: 'string', length: 400)]
private $descriptions;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $image;
#[ORM\Column(type: 'string', length: 255)]
private $nameFr;
#[ORM\Column(type: 'string', length: 400)]
private $descriptionsFr;
#[ORM\Column(type: 'string', length: 255)]
private $nameEs;
#[ORM\Column(type: 'string', length: 400)]
private $descriptionsEs;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'CategorieChild')]
private $sousCategorie;
#[ORM\OneToMany(mappedBy: 'sousCategorie', targetEntity: self::class)]
private $CategorieChild;
#[ORM\ManyToMany(targetEntity: Produit::class, mappedBy: 'Categories')]
private $produits;
public function __construct()
{
$this->CategorieChild = new ArrayCollection();
$this->produits = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDescriptions(): ?string
{
return $this->descriptions;
}
public function setDescriptions(string $descriptions): self
{
$this->descriptions = $descriptions;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getNameFr(): ?string
{
return $this->nameFr;
}
public function setNameFr(string $nameFr): self
{
$this->nameFr = $nameFr;
return $this;
}
public function getDescriptionsFr(): ?string
{
return $this->descriptionsFr;
}
public function setDescriptionsFr(string $descriptionsFr): self
{
$this->descriptionsFr = $descriptionsFr;
return $this;
}
public function getNameEs(): ?string
{
return $this->nameEs;
}
public function setNameEs(string $nameEs): self
{
$this->nameEs = $nameEs;
return $this;
}
public function getDescriptionsEs(): ?string
{
return $this->descriptionsEs;
}
public function setDescriptionsEs(string $descriptionsEs): self
{
$this->descriptionsEs = $descriptionsEs;
return $this;
}
public function getNameLangue($langueCurrent){
if ($langueCurrent == "fr"){
return $this->getNameFr();
}elseif ($langueCurrent == "en"){
return $this->getName();
}elseif ($langueCurrent == "es"){
return $this->getNameEs();
}else{
return $this->getNameFr();
}
}
public function getDescriptionsLangue($langueCurrent){
if ($langueCurrent == "fr"){
return $this->getDescriptionsFr();
}elseif ($langueCurrent == "en"){
return $this->getDescriptions();
}elseif ($langueCurrent == "es"){
return $this->getDescriptionsEs();
}else{
return $this->getDescriptionsFr();
}
}
public function getSousCategorie(): ?self
{
return $this->sousCategorie;
}
public function setSousCategorie(?self $sousCategorie): self
{
$this->sousCategorie = $sousCategorie;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getCategorieChild(): Collection
{
return $this->CategorieChild;
}
public function addCategorieChild(self $categorieChild): self
{
if (!$this->CategorieChild->contains($categorieChild)) {
$this->CategorieChild[] = $categorieChild;
$categorieChild->setSousCategorie($this);
}
return $this;
}
public function removeCategorieChild(self $categorieChild): self
{
if ($this->CategorieChild->removeElement($categorieChild)) {
// set the owning side to null (unless already changed)
if ($categorieChild->getSousCategorie() === $this) {
$categorieChild->setSousCategorie(null);
}
}
return $this;
}
/**
* @return Collection<int, Produit>
*/
public function getProduits(): Collection
{
return $this->produits;
}
public function addProduit(Produit $produit): self
{
if (!$this->produits->contains($produit)) {
$this->produits[] = $produit;
$produit->addCategory($this);
}
return $this;
}
public function removeProduit(Produit $produit): self
{
if ($this->produits->removeElement($produit)) {
$produit->removeCategory($this);
}
return $this;
}
}