<?php
namespace App\Core\Entity;
use App\Core\Entity\CategoriaUsuario;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @ORM\Entity(repositoryClass="App\Core\Repository\CategoriaRepository")
*/
class Categoria
{
CONST JSON_FIELDS = ['id', 'nombre', 'nombreCompletoEs', 'nombreCompletoEn', 'imageName'];
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=30, unique=true)
*/
private $nombre;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $nombreCompletoEs;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $nombreCompletoEn;
/**
* @ORM\Column(type="string", length=200, nullable=false)
*
* @var string|null
*/
private $imageName;
/**
* @ORM\OneToMany(targetEntity="App\Core\Entity\CategoriaCurso", mappedBy="categoria")
*/
private $cursosCategoria;
/**
* @ORM\OneToMany(targetEntity="App\Core\Entity\CategoriaUsuario", mappedBy="categoria", orphanRemoval=true)
*/
private $categoriaUsuarios;
public function __construct()
{
$this->cursosCategoria = new ArrayCollection();
$this->categoriaUsuarios = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(string $nombre): self
{
$this->nombre = $nombre;
return $this;
}
/**
* @return Collection|CategoriaCurso[]
*/
public function getCursosCategoria(): Collection
{
return $this->cursosCategoria;
}
public function addCategoriaCurso(CategoriaCurso $categoriaCurso): self
{
if (!$this->cursosCategoria->contains($categoriaCurso)) {
$this->cursosCategoria[] = $categoriaCurso;
$categoriaCurso->setCategoria($this);
}
return $this;
}
public function removeCategoriaCurso(CategoriaCurso $categoriaCurso): self
{
if ($this->cursosCategoria->contains($categoriaCurso)) {
$this->cursosCategoria->removeElement($categoriaCurso);
// set the owning side to null (unless already changed)
if ($categoriaCurso->getCategoria() === $this) {
$categoriaCurso->setCategoria(null);
}
}
return $this;
}
/**
* @return Collection|CategoriaUsuario[]
*/
public function getCategoriaUsuarios(): Collection
{
return $this->categoriaUsuarios;
}
public function addCategoriaUsuario(CategoriaUsuario $categoriaUsuario): self
{
if (!$this->categoriaUsuarios->contains($categoriaUsuario)) {
$this->categoriaUsuarios[] = $categoriaUsuario;
$categoriaUsuario->setCategoria($this);
}
return $this;
}
public function removeCategoriaUsuario(CategoriaUsuario $categoriaUsuario): self
{
if ($this->categoriaUsuarios->contains($categoriaUsuario)) {
$this->categoriaUsuarios->removeElement($categoriaUsuario);
// set the owning side to null (unless already changed)
if ($categoriaUsuario->getCategoria() === $this) {
$categoriaUsuario->setCategoria(null);
}
}
return $this;
}
public function setImageName(?string $imageName): void
{
$this->imageName = $imageName;
}
public function getImageName(): ?string
{
return $this->imageName;
}
public function getNombreCompleto(): ?string
{
if($GLOBALS['request']->getLocale() === 'es')
return $this->nombreCompletoEs;
elseif ($GLOBALS['request']->getLocale() === 'en')
return $this->nombreCompletoEn;
else
return $this->nombreCompletoEn;
}
public function getNombreCompletoEs(): ?string
{
return $this->nombreCompletoEs;
}
public function setNombreCompletoEs(string $nombreCompletoEs): self
{
$this->nombreCompletoEs = $nombreCompletoEs;
return $this;
}
public function getNombreCompletoEn(): ?string
{
return $this->nombreCompletoEn;
}
public function setNombreCompletoEn(string $nombreCompletoEn): self
{
$this->nombreCompletoEn = $nombreCompletoEn;
return $this;
}
}