You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
3.5 KiB
142 lines
3.5 KiB
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/* For licensing terms, see /license.txt */
|
|
|
|
namespace Chamilo\CoreBundle\Entity;
|
|
|
|
use ApiPlatform\Core\Annotation\ApiFilter;
|
|
use ApiPlatform\Core\Annotation\ApiResource;
|
|
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
|
|
use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
|
|
use Chamilo\CoreBundle\Repository\LanguageRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Annotation\Groups;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
/**
|
|
* Platform languages.
|
|
*/
|
|
#[ApiResource]
|
|
#[ApiFilter(BooleanFilter::class, properties: ['available'])]
|
|
#[ApiFilter(OrderFilter::class, properties: ['english_name' => 'DESC'])]
|
|
#[ORM\Table(name: 'language', options: ['row_format' => 'DYNAMIC'])]
|
|
#[ORM\Entity(repositoryClass: LanguageRepository::class)]
|
|
class Language
|
|
{
|
|
#[Groups(['language:read'])]
|
|
#[ORM\Column(name: 'id', type: 'integer')]
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
protected ?int $id = null;
|
|
|
|
#[Groups(['language:read', 'language:write'])]
|
|
#[Assert\NotBlank]
|
|
#[ORM\Column(name: 'original_name', type: 'string', length: 255, nullable: true)]
|
|
protected ?string $originalName = null;
|
|
|
|
#[Groups(['language:read', 'language:write'])]
|
|
#[Assert\NotBlank]
|
|
#[ORM\Column(name: 'english_name', type: 'string', length: 255)]
|
|
protected string $englishName;
|
|
|
|
#[Groups(['language:read', 'language:write'])]
|
|
#[Assert\NotBlank]
|
|
#[ORM\Column(name: 'isocode', type: 'string', length: 10)]
|
|
protected string $isocode;
|
|
|
|
#[Groups(['language:read', 'language:write'])]
|
|
#[ORM\Column(name: 'available', type: 'boolean', nullable: false)]
|
|
protected bool $available;
|
|
|
|
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'subLanguages')]
|
|
#[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id', nullable: true)]
|
|
protected ?Language $parent = null;
|
|
|
|
#[Groups(['language:read', 'language:write'])]
|
|
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
|
|
protected Collection $subLanguages;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->subLanguages = new ArrayCollection();
|
|
}
|
|
|
|
public function setOriginalName(string $originalName): self
|
|
{
|
|
$this->originalName = $originalName;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getOriginalName(): string
|
|
{
|
|
return $this->originalName;
|
|
}
|
|
|
|
public function setEnglishName(string $englishName): self
|
|
{
|
|
$this->englishName = $englishName;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getEnglishName(): string
|
|
{
|
|
return $this->englishName;
|
|
}
|
|
|
|
public function setIsocode(string $isocode): self
|
|
{
|
|
$this->isocode = $isocode;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getIsocode(): string
|
|
{
|
|
return $this->isocode;
|
|
}
|
|
|
|
public function setAvailable(bool $available): self
|
|
{
|
|
$this->available = $available;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getAvailable(): bool
|
|
{
|
|
return $this->available;
|
|
}
|
|
|
|
public function setParent(self $parent): self
|
|
{
|
|
$this->parent = $parent;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getParent(): ?self
|
|
{
|
|
return $this->parent;
|
|
}
|
|
|
|
public function getSubLanguages(): Collection
|
|
{
|
|
return $this->subLanguages;
|
|
}
|
|
|
|
/**
|
|
* Get id.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function getId()
|
|
{
|
|
return $this->id;
|
|
}
|
|
}
|
|
|