Skip to content

Commit

Permalink
Improve README code examples by adding use statements (#60)
Browse files Browse the repository at this point in the history
for people who cut and paste...
  • Loading branch information
tacman authored Apr 9, 2024
1 parent e7b8dd1 commit e5d06c5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Let's say you have an existing Doctrine entity `Document` that looks like this:

```php
<?php
namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down Expand Up @@ -106,6 +107,8 @@ This will lead you to something like the following, with some code skipped for b
```php
<?php

namespace App\Entity;

use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
Expand Down Expand Up @@ -153,9 +156,13 @@ Your code should look similar to this:

```php
<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Webfactory\Bundle\PolyglotBundle\Entity\BaseTranslation;
use Webfactory\Bundle\PolyglotBundle\Attribute as Polyglot;
use Webfactory\Bundle\PolyglotBundle\TranslatableInterface;

#[ORM\Table]
#[ORM\UniqueConstraint(columns: ['entity_id', 'locale'])]
Expand All @@ -171,7 +178,7 @@ class DocumentTranslation
#[Polyglot\Locale]
private string $locale;

#[ORM\ManyToOne(targetEntity: \Document::class, inversedBy: 'translations')]
#[ORM\ManyToOne(targetEntity: Document::class, inversedBy: 'translations')]
private Document $entity;

public function getLocale(): string
Expand Down

0 comments on commit e5d06c5

Please sign in to comment.