Sfoglia il codice sorgente

Fix #128 - Have to clear cache after adding a new admin

Thomas Rabaix 14 anni fa
parent
commit
eefe79cca5

+ 1 - 1
DependencyInjection/Compiler/AddDependencyCallsPass.php

@@ -79,7 +79,7 @@ class AddDependencyCallsPass implements CompilerPassInterface
         $pool->addMethodCall('setAdminClasses', array($classes));
 
         $routeLoader = $container->getDefinition('sonata.admin.route_loader');
-        $routeLoader->addArgument($admins);
+        $routeLoader->replaceArgument(1, $admins);
     }
 
     /**

+ 2 - 0
Resources/config/core.xml

@@ -11,6 +11,8 @@
 
         <service id="sonata.admin.route_loader" class="Sonata\AdminBundle\Route\AdminPoolLoader">
             <argument type="service" id="sonata.admin.pool" />
+            <argument />
+            <argument type="service" id="service_container" />
             <tag name="routing.loader" />
         </service>
 

+ 9 - 3
Route/AdminPoolLoader.php

@@ -31,14 +31,17 @@ class AdminPoolLoader extends FileLoader
      */
     protected $adminServiceIds = array();
 
+    protected $container;
+
     /**
      * @param \Sonata\AdminBundle\Admin\Pool $pool
      * @param  $adminServiceIds
      */
-    public function __construct(Pool $pool, $adminServiceIds)
+    public function __construct(Pool $pool, $adminServiceIds, $container)
     {
-        $this->pool = $pool;
-        $this->adminServiceIds = $adminServiceIds;
+        $this->pool             = $pool;
+        $this->adminServiceIds  = $adminServiceIds;
+        $this->container        = $container;
     }
 
     /**
@@ -75,6 +78,9 @@ class AdminPoolLoader extends FileLoader
             $collection->addResource(new FileResource($reflection->getFileName()));
         }
 
+        $reflection = new \ReflectionObject($this->container);
+        $collection->addResource(new FileResource($reflection->getFileName()));
+
         return $collection;
     }
 }

+ 0 - 1
Route/RouteCollection.php

@@ -48,7 +48,6 @@ class RouteCollection
      */
     public function add($name, $pattern = null, array $defaults = array(), array $requirements = array(), array $options = array())
     {
-
         $pattern    = sprintf('%s/%s', $this->baseRoutePattern, $pattern ?: $name);
         $code       = sprintf('%s.%s', $this->baseCodeRoute, $name);
         $name       = sprintf('%s_%s', $this->baseRouteName, $name);