Explorar o código

Restored multiple level model class name support in base route generation

Willem Luijt %!s(int64=11) %!d(string=hai) anos
pai
achega
069c386cf0
Modificáronse 2 ficheiros con 33 adicións e 1 borrados
  1. 1 1
      Admin/Admin.php
  2. 32 0
      Tests/Admin/BaseAdminTest.php

+ 1 - 1
Admin/Admin.php

@@ -52,7 +52,7 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
     const CONTEXT_MENU       = 'menu';
     const CONTEXT_DASHBOARD  = 'dashboard';
 
-    const CLASS_REGEX        = '@([A-Za-z0-9]*)\\\(Bundle\\\)?([A-Za-z0-9]+)Bundle\\\([A-Za-z0-9].*)\\\([A-Za-z0-9]*)$@';
+    const CLASS_REGEX        = '@([A-Za-z0-9]*)\\\(Bundle\\\)?([A-Za-z0-9]+)Bundle\\\(Entity|Document|Model|PHPCR|Doctrine\\\Phpcr)\\\(.*)@';
 
     /**
      * The class name managed by the admin class

+ 32 - 0
Tests/Admin/BaseAdminTest.php

@@ -156,6 +156,18 @@ class BaseAdminTest extends \PHPUnit_Framework_TestCase
                 'MyApplication\MyBundle\Entity\Post', 
                 '/myapplication/my/post'
             ),
+            array(
+                'MyApplication\MyBundle\Entity\Post\Category',
+                '/myapplication/my/post-category'
+            ),
+            array(
+                'MyApplication\MyBundle\Entity\Product\Category',
+                '/myapplication/my/product-category'
+            ),
+            array(
+                'MyApplication\MyBundle\Entity\Other\Product\Category',
+                '/myapplication/my/other-product-category'
+            ),
             array(
                 'Symfony\Cmf\Bundle\FooBundle\Document\Menu', 
                 '/cmf/foo/menu'
@@ -168,6 +180,10 @@ class BaseAdminTest extends \PHPUnit_Framework_TestCase
                 'Symfony\Bundle\BarBarBundle\Doctrine\Phpcr\Menu', 
                 '/symfony/barbar/menu'
             ),
+            array(
+                'Symfony\Bundle\BarBarBundle\Doctrine\Phpcr\Menu\Item',
+                '/symfony/barbar/menu-item'
+            ),
         );
     }
 
@@ -213,6 +229,18 @@ class BaseAdminTest extends \PHPUnit_Framework_TestCase
                 'MyApplication\MyBundle\Entity\Post', 
                 'admin_myapplication_my_post'
             ),
+            array(
+                'MyApplication\MyBundle\Entity\Post\Category',
+                'admin_myapplication_my_post_category'
+            ),
+            array(
+                'MyApplication\MyBundle\Entity\Product\Category',
+                'admin_myapplication_my_product_category'
+            ),
+            array(
+                'MyApplication\MyBundle\Entity\Other\Product\Category',
+                'admin_myapplication_my_other_product_category'
+            ),
             array(
                 'Symfony\Cmf\Bundle\FooBundle\Document\Menu', 
                 'admin_cmf_foo_menu'
@@ -225,6 +253,10 @@ class BaseAdminTest extends \PHPUnit_Framework_TestCase
                 'Symfony\Bundle\BarBarBundle\Doctrine\Phpcr\Menu', 
                 'admin_symfony_barbar_menu'
             ),
+            array(
+                'Symfony\Bundle\BarBarBundle\Doctrine\Phpcr\Menu\Item',
+                'admin_symfony_barbar_menu_item'
+            ),
         );
     }