瀏覽代碼

update code to work with the last symfony changes

Thomas 14 年之前
父節點
當前提交
eb4b977408
共有 3 個文件被更改,包括 15 次插入14 次删除
  1. 8 9
      Admin/Admin.php
  2. 3 2
      DependencyInjection/BaseApplicationExtension.php
  3. 4 3
      Route/AdminPoolLoader.php

+ 8 - 9
Admin/Admin.php

@@ -377,9 +377,8 @@ abstract class Admin extends ContainerAware
      */
     public function getBaseRoutePattern()
     {
-
         if (!$this->baseRoutePattern) {
-            preg_match('@(Application|Bundle)\\\([A-Za-z]*)\\\([A-Za-z]*)Bundle\\\(Entity|Document)\\\([A-Za-z]*)@', $this->getClass(), $matches);
+            preg_match('@([A-Za-z]*)\\\([A-Za-z]*)Bundle\\\(Entity|Document)\\\([A-Za-z]*)@', $this->getClass(), $matches);
 
             if(!$matches) {
                 throw new \RuntimeException(sprintf('Please define a default `baseRoutePattern` value for the admin class `%s`', get_class($this)));
@@ -388,14 +387,14 @@ abstract class Admin extends ContainerAware
             if ($this->isChild()) { // the admin class is a child, prefix it with the parent route name
                 $this->baseRoutePattern = sprintf('%s/{id}/%s',
                     $this->getParent()->getBaseRoutePattern(),
-                    $this->urlize($matches[5], '-')
+                    $this->urlize($matches[4], '-')
                 );
             } else {
 
                 $this->baseRoutePattern = sprintf('/%s/%s/%s',
+                    $this->urlize($matches[1], '-'),
                     $this->urlize($matches[2], '-'),
-                    $this->urlize($matches[3], '-'),
-                    $this->urlize($matches[5], '-')
+                    $this->urlize($matches[4], '-')
                 );
             }
         }
@@ -412,7 +411,7 @@ abstract class Admin extends ContainerAware
     public function getBaseRouteName()
     {
         if (!$this->baseRouteName) {
-            preg_match('@(Application|Bundle)\\\([A-Za-z]*)\\\([A-Za-z]*)Bundle\\\(Entity|Document)\\\([A-Za-z]*)@', $this->getClass(), $matches);
+            preg_match('@([A-Za-z]*)\\\([A-Za-z]*)Bundle\\\(Entity|Document)\\\([A-Za-z]*)@', $this->getClass(), $matches);
 
             if(!$matches) {
                 throw new \RuntimeException(sprintf('Please define a default `baseRouteName` value for the admin class `%s`', get_class($this)));
@@ -421,14 +420,14 @@ abstract class Admin extends ContainerAware
             if ($this->isChild()) { // the admin class is a child, prefix it with the parent route name
                 $this->baseRouteName = sprintf('%s_%s',
                     $this->getParent()->getBaseRouteName(),
-                    $this->urlize($matches[5])
+                    $this->urlize($matches[4])
                 );
             } else {
 
                 $this->baseRouteName = sprintf('admin_%s_%s_%s',
+                    $this->urlize($matches[1]),
                     $this->urlize($matches[2]),
-                    $this->urlize($matches[3]),
-                    $this->urlize($matches[5])
+                    $this->urlize($matches[4])
                 );
             }
         }

+ 3 - 2
DependencyInjection/BaseApplicationExtension.php

@@ -12,12 +12,13 @@
 namespace Sonata\BaseApplicationBundle\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
-use Symfony\Component\DependencyInjection\Resource\FileResource;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Reference;
 use Symfony\Component\DependencyInjection\Definition;
 use Symfony\Component\DependencyInjection\Extension\Extension;
-use Symfony\Component\DependencyInjection\Loader\FileLocator;
+
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\Config\Resource\FileResource;
 
 use Symfony\Component\Finder\Finder;
 

+ 4 - 3
Route/AdminPoolLoader.php

@@ -13,12 +13,13 @@ namespace Sonata\BaseApplicationBundle\Route;
 
 use Symfony\Component\Routing\RouteCollection;
 use Symfony\Component\Routing\Route;
-use Symfony\Component\Routing\Loader\Loader;
+    
+use Symfony\Component\Config\Loader\FileLoader;
+use Symfony\Component\Config\Resource\FileResource;
 
-use Symfony\Component\Routing\Resource\FileResource;
 use Sonata\BaseApplicationBundle\Admin\Pool;
 
-class AdminPoolLoader extends Loader
+class AdminPoolLoader extends FileLoader
 {
     /**
      * @var Bundle\Soanta\BaseApplicationBundle\Admin\Pool