<?php
namespace App\Entity;
use App\Repository\PageRepository;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: PageRepository::class)]
class Page implements TranslatableInterface
{
use TranslatableTrait;
public const CODE = [
'ETHICAL_CHART' => 'ethical_chart',
'PUBLISHING_CONDITIONS' => 'publishing_conditions',
'TERMS_OF_SERVICE' => 'terms_of_service',
];
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[Assert\Valid]
protected $translations;
#[ORM\Column(length: 255, unique: true)]
#[Assert\NotBlank]
private string $code;
public function getId(): ?int
{
return $this->id;
}
public function getCode(): string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function __call($method, $arguments)
{
return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), $method);
}
public function __get($name)
{
$method = 'get'.ucfirst($name);
return $this->proxyCurrentLocaleTranslation($method, []);
}
}