Parcourir la source

Fixed backwards compatibility and added test

Joris van de Sande il y a 12 ans
Parent
commit
5c8d59c8b2
2 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 6 1
      Admin/Admin.php
  2. 1 0
      Tests/Admin/BaseAdminTest.php

+ 6 - 1
Admin/Admin.php

@@ -1087,7 +1087,12 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
     {
         $this->buildRoutes();
 
-        if (! $this->isChild() && strpos($name, '.') !== false) {
+        if (
+            ! $this->isChild()
+            && strpos($name, '.') !== false
+            && strpos($name, $this->getBaseCodeRoute() . '|') !== 0
+            && strpos($name, $this->getBaseCodeRoute() . '.') !== 0
+        ) {
             $name = $this->getCode() . '|' . $name;
         }
 

+ 1 - 0
Tests/Admin/BaseAdminTest.php

@@ -179,6 +179,7 @@ class BaseAdminTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($postAdmin->hasRoute('show'));
         $this->assertTrue($postAdmin->hasRoute('sonata.post.admin.post.show'));
         $this->assertTrue($postAdmin->hasRoute('sonata.post.admin.post|sonata.post.admin.comment.show'));
+        $this->assertTrue($postAdmin->hasRoute('sonata.post.admin.comment.list'));
 
         $this->assertFalse($postAdmin->hasRoute('sonata.post.admin.post|sonata.post.admin.comment.edit'));
         $this->assertFalse($commentAdmin->hasRoute('edit'));