src/Entity/Page.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PageRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  6. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  7. use Symfony\Component\PropertyAccess\PropertyAccess;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassPageRepository::class)]
  10. class Page implements TranslatableInterface
  11. {
  12.     use TranslatableTrait;
  13.     public const CODE = [
  14.         'ETHICAL_CHART' => 'ethical_chart',
  15.         'PUBLISHING_CONDITIONS' => 'publishing_conditions',
  16.         'TERMS_OF_SERVICE' => 'terms_of_service',
  17.     ];
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column(type'integer')]
  21.     private $id;
  22.     #[Assert\Valid]
  23.     protected $translations;
  24.     #[ORM\Column(length255uniquetrue)]
  25.     #[Assert\NotBlank]
  26.     private string $code;
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getCode(): string
  32.     {
  33.         return $this->code;
  34.     }
  35.     public function setCode(string $code): self
  36.     {
  37.         $this->code $code;
  38.         return $this;
  39.     }
  40.     public function __call($method$arguments)
  41.     {
  42.         return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), $method);
  43.     }
  44.     public function __get($name)
  45.     {
  46.         $method 'get'.ucfirst($name);
  47.         return $this->proxyCurrentLocaleTranslation($method, []);
  48.     }
  49. }