|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Webfactory\Bundle\PolyglotBundle\Tests\Fixtures\Entity\EntityInheritance; |
| 4 | + |
| 5 | +use Doctrine\Common\Collections\ArrayCollection; |
| 6 | +use Doctrine\Common\Collections\Collection; |
| 7 | +use Doctrine\ORM\Mapping as ORM; |
| 8 | +use Webfactory\Bundle\PolyglotBundle\Attribute as Polyglot; |
| 9 | +use Webfactory\Bundle\PolyglotBundle\TranslatableInterface; |
| 10 | + |
| 11 | +#[Polyglot\Locale(primary: 'en_GB')] |
| 12 | +#[ORM\Entity] |
| 13 | +#[ORM\InheritanceType(value: 'SINGLE_TABLE')] |
| 14 | +#[ORM\DiscriminatorMap(['base' => 'EntityInheritance_BaseEntityClass', 'child' => 'EntityInheritance_ChildEntityClass'])] |
| 15 | +#[ORM\DiscriminatorColumn(name: 'discriminator', type: 'string')] |
| 16 | +class EntityInheritance_BaseEntityClass |
| 17 | +{ |
| 18 | + #[ORM\Column(type: 'integer')] |
| 19 | + #[ORM\Id] |
| 20 | + #[ORM\GeneratedValue] |
| 21 | + private ?int $id = null; |
| 22 | + |
| 23 | + private string $discriminator; |
| 24 | + |
| 25 | + #[Polyglot\TranslationCollection] |
| 26 | + #[ORM\OneToMany(targetEntity: EntityInheritance_BaseEntityClassTranslation::class, mappedBy: 'entity')] |
| 27 | + private Collection $translations; |
| 28 | + |
| 29 | + #[Polyglot\Translatable] |
| 30 | + #[ORM\Column(type: 'string')] |
| 31 | + private TranslatableInterface|string|null $text = null; |
| 32 | + |
| 33 | + public function __construct() |
| 34 | + { |
| 35 | + $this->translations = new ArrayCollection(); |
| 36 | + } |
| 37 | + |
| 38 | + public function getId(): int |
| 39 | + { |
| 40 | + return $this->id; |
| 41 | + } |
| 42 | + |
| 43 | + public function setText(TranslatableInterface $text): void |
| 44 | + { |
| 45 | + $this->text = $text; |
| 46 | + } |
| 47 | + |
| 48 | + public function getText(): TranslatableInterface |
| 49 | + { |
| 50 | + return $this->text; |
| 51 | + } |
| 52 | +} |
0 commit comments