-
Notifications
You must be signed in to change notification settings - Fork 3
Description
I'm trying to follow the documentation, and can't figure out how this works (from the README)
<?php
use Doctrine\ORM\Mapping as ORM;
use Webfactory\Bundle\PolyglotBundle\Entity\BaseTranslation;
#[ORM\Table]
#[ORM\UniqueConstraint(columns: ['entity_id', 'locale'])]
#[ORM\Entity]
class DocumentTranslation
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private int $id;
#[ORM\Column]
#[Polyglot\Locale]
private string $locale;
#[ORM\ManyToOne(targetEntity: \Document::class, inversedBy: 'translations')]
private Document $entity;
public function getLocale(): string
{
return $this->locale;
}
#[ORM\Column]
private string $text;
}text, locale and entity are all private, yet they're never set. Is this something that happens in the constructor? Or a listener somewhere? I'm confused as to how it works.
On a related note, while I understand what text and entity are, they're confusing (to me) in the documentation. Text and Entity are also types. Would you consider changing the field names to 'title' and 'description' (a string and text field) and changing the documentation to use those names instead? getText() to me too generic, it's hard to remember that it's the text field, not the text of the document, would would be of a text type, but a string in your example, so when you say document->getText() you're only getting a 255 character field in most databases. Thus my confusion.
shouldn't $locale be protected? I dunno, I'm just stabbing here. Is there a public repo that uses this, if I can see it in action I'm sure I can figure it out.
Thanks! I look forward to using this.
I submitted a PR that adds namespaces and more use statements.