Skip to content

Commit

Permalink
Fixed incorrect translation of entity names (sonata-project#4087)
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 authored and OskarStark committed Aug 22, 2016
1 parent 4a34c3b commit 24be8ff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Admin/BreadcrumbsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ public function buildBreadcrumbs(AdminInterface $admin, $action, ItemInterface $
'uri' => $admin->hasRoute($this->config['child_admin_route']) && $admin->hasAccess($this->config['child_admin_route'], $admin->getSubject()) ?
$admin->generateUrl($this->config['child_admin_route'], array('id' => $id)) :
null,
'extras' => array(
'translation_domain' => false,
),
)
);

Expand All @@ -123,7 +126,11 @@ public function buildBreadcrumbs(AdminInterface $admin, $action, ItemInterface $
if ('list' === $action && $admin->isChild()) {
$menu->setUri(false);
} elseif ('create' !== $action && $admin->hasSubject()) {
$menu = $menu->addChild($admin->toString($admin->getSubject()));
$menu = $menu->addChild($admin->toString($admin->getSubject()), array(
'extras' => array(
'translation_domain' => false,
),
));
} else {
$menu = $this->createMenuItem(
$admin,
Expand Down
19 changes: 16 additions & 3 deletions Tests/Admin/BreadcrumbsBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ public function testUnitChildGetBreadCrumbs()

$adminListMenu->addChild('My subject', array(
'uri' => '/myadmin/my-object',
'extras' => array(
'translation_domain' => false,
),
))->shouldBeCalled()->willReturn($adminSubjectMenu->reveal());

$adminSubjectMenu->addChild('My child class', array(
Expand All @@ -414,8 +417,11 @@ public function testUnitChildGetBreadCrumbs()
))->shouldBeCalled()->willReturn($childMenu->reveal());
$adminSubjectMenu->setExtra('safe_label', false)->willReturn($childMenu);

$childMenu->addChild('My subject')
->shouldBeCalled()->willReturn($leafMenu->reveal());
$childMenu->addChild('My subject', array(
'extras' => array(
'translation_domain' => false,
),
))->shouldBeCalled()->willReturn($leafMenu->reveal());

$breadcrumbs = $breadcrumbsBuilder->getBreadcrumbs($childAdmin->reveal(), $action);
$this->assertCount(5, $breadcrumbs);
Expand Down Expand Up @@ -529,9 +535,16 @@ public function testUnitBuildBreadcrumbs($action)
'translation_domain' => 'FooBundle',
),
))->willReturn($menu->reveal());
$menu->addChild('My subject')->willReturn($menu);
$menu->addChild('My subject', array(
'extras' => array(
'translation_domain' => false,
),
))->willReturn($menu);
$menu->addChild('My subject', array(
'uri' => null,
'extras' => array(
'translation_domain' => false,
),
))->willReturn($menu);
$menu->addChild('My child class', array(
'extras' => array(
Expand Down

0 comments on commit 24be8ff

Please sign in to comment.