<?php
namespace App\Entity;
use App\Repository\TranslationRepository;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\UniqueConstraint;
use Gedmo\Blameable\Traits\BlameableEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: TranslationRepository::class)]
#[UniqueConstraint(name: "unique_language_translation_per_key_constraint", columns: ["key", "language"])]
#[UniqueEntity(fields: ["key", "language"], errorPath: 'key')]
class Translation
{
use TimestampableEntity; //Hook timestampable behaviour. Updates createdAt, updatedAt fields
use BlameableEntity; //Hook blameable behaviour. Updates createdBy, updatedBy fields
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "IDENTITY")]
#[ORM\Column()]
private ?int $id = null;
#[ORM\Column(length: 2)]
#[Assert\NotNull()]
#[Assert\Length(max: 2)]
private ?string $language;
#[ORM\Column(length: 255)]
#[Assert\NotNull()]
#[Assert\Length(max: 255)]
private ?string $key;
#[ORM\Column(length: 500)]
#[Assert\NotNull()]
#[Assert\Length(max: 500)]
private ?string $translation;
#[ORM\Column(length: 255)]
#[Assert\NotNull()]
#[Assert\Length(max: 255)]
private ?string $domain;
public function __toString()
{
return $this->getLanguage() . ' - ' . $this->getKey();
}
public function getId(): ?int
{
return $this->id;
}
public function getLanguage(): ?string
{
return $this->language;
}
public function setLanguage(string $language): self
{
$this->language = $language;
return $this;
}
public function getKey(): ?string
{
return $this->key;
}
public function setKey(string $key): self
{
$this->key = $key;
return $this;
}
public function getTranslation(): ?string
{
return $this->translation;
}
public function setTranslation(string $translation): self
{
$this->translation = $translation;
return $this;
}
public function getDomain(): ?string
{
return $this->domain;
}
public function setDomain(string $domain): self
{
$this->domain = $domain;
return $this;
}
}