Skip to content

Commit 543e707

Browse files
authored
minor #934 Reproduce getting the translation repository by its interface use case (loic425)
This PR was merged into the 1.11 branch. Discussion ---------- | Q | A | --------------- | ----- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | | License | MIT On 1.12 branch ![image](https://github.com/user-attachments/assets/46e22535-0a7a-4dc0-bd33-2fc115329bbc) Commits ------- b4e0976 Reproduce getting the translation repository by its interface use case
2 parents 75f314d + b4e0976 commit 543e707

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

tests/Application/config/sylius/resources.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ sylius_resource:
2323
translation:
2424
classes:
2525
model: App\Entity\BookTranslation
26+
interface: App\Entity\BookTranslationInterface
2627
form: App\Form\Type\BookTranslationType
2728

2829
app.comic_book:

tests/Application/src/Entity/BookTranslation.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515

1616
use Doctrine\ORM\Mapping as ORM;
1717
use Sylius\Resource\Model\AbstractTranslation;
18-
use Sylius\Resource\Model\ResourceInterface;
1918

2019
#[ORM\Entity]
2120
#[ORM\MappedSuperclass]
2221
#[ORM\Table(name: 'app_book_translation')]
23-
class BookTranslation extends AbstractTranslation implements ResourceInterface
22+
class BookTranslation extends AbstractTranslation implements BookTranslationInterface
2423
{
2524
#[ORM\Id]
2625
#[ORM\GeneratedValue]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace App\Entity;
15+
16+
use Sylius\Resource\Model\ResourceInterface;
17+
18+
interface BookTranslationInterface extends ResourceInterface
19+
{
20+
public function getTitle(): ?string;
21+
22+
public function setTitle(?string $title): void;
23+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Bundle\EventListener;
15+
16+
use App\Entity\BookTranslationInterface;
17+
use Doctrine\ORM\EntityManagerInterface;
18+
use Doctrine\ORM\EntityRepository;
19+
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
20+
21+
final class ORMTranslatableListenerTest extends KernelTestCase
22+
{
23+
public function testGettingTranslationRepositoryByItsInterface(): void
24+
{
25+
self::bootKernel();
26+
27+
$this->assertInstanceOf(
28+
EntityRepository::class,
29+
$this->getEntityManager()->getRepository(BookTranslationInterface::class),
30+
);
31+
}
32+
33+
private function getEntityManager(): EntityManagerInterface
34+
{
35+
return $this->getContainer()->get(EntityManagerInterface::class);
36+
}
37+
}

0 commit comments

Comments
 (0)