Bladeren bron

added Bundles and Extensions in the list of resources to monitor in dev environment

Fabien Potencier 15 jaren geleden
bovenliggende
commit
aa697d8a0c

+ 17 - 1
src/Symfony/Components/DependencyInjection/BuilderConfiguration.php

@@ -49,7 +49,7 @@ class BuilderConfiguration
      */
     public function getResources()
     {
-        return $this->resources;
+        return array_unique($this->resources);
     }
 
     /**
@@ -103,6 +103,8 @@ class BuilderConfiguration
     {
         $namespace = $extension->getAlias();
 
+        $this->addObjectResource($extension);
+
         if (!isset($this->extensions[$namespace])) {
             $this->extensions[$namespace] = new self();
 
@@ -115,6 +117,20 @@ class BuilderConfiguration
         return $this;
     }
 
+    /**
+     * Adds the object class hierarchy as resources.
+     *
+     * @param object $object An object instance
+     */
+    public function addObjectResource($object)
+    {
+        $parent = new \ReflectionObject($object);
+        $this->addResource(new FileResource($parent->getFileName()));
+        while ($parent = $parent->getParentClass()) {
+            $this->addResource(new FileResource($parent->getFileName()));
+        }
+    }
+
     /**
      * Merges the extension configuration.
      *

+ 11 - 1
src/Symfony/Components/DependencyInjection/Resource/FileResource.php

@@ -29,7 +29,17 @@ class FileResource implements ResourceInterface
      */
     public function __construct($resource)
     {
-        $this->resource = $resource;
+        $this->resource = realpath($resource);
+    }
+
+    /**
+     * Returns a string representation of the Resource.
+     *
+     * @return string A string representation of the Resource
+     */
+    public function __toString()
+    {
+        return $this->resource;
     }
 
     /**

+ 7 - 0
src/Symfony/Components/DependencyInjection/Resource/ResourceInterface.php

@@ -20,6 +20,13 @@ namespace Symfony\Components\DependencyInjection\Resource;
  */
 interface ResourceInterface
 {
+    /**
+     * Returns a string representation of the Resource.
+     *
+     * @return string A string representation of the Resource
+     */
+    function __toString();
+
     /**
      * Returns true if the resource has not been updated since the given timestamp.
      *

+ 5 - 6
src/Symfony/Foundation/Kernel.php

@@ -343,6 +343,10 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
         $configuration = new BuilderConfiguration();
         foreach ($this->bundles as $bundle) {
             $configuration->merge($bundle->buildContainer($container));
+
+            if ($this->debug) {
+                $configuration->addObjectResource($bundle);
+            }
         }
         $configuration->merge($this->registerContainerConfiguration());
         $container->merge($configuration);
@@ -368,12 +372,7 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
         $this->writeCacheFile($file, $content);
 
         if ($this->debug) {
-            // add the Kernel class hierarchy as resources
-            $parent = new \ReflectionObject($this);
-            $configuration->addResource(new FileResource($parent->getFileName()));
-            while ($parent = $parent->getParentClass()) {
-                $configuration->addResource(new FileResource($parent->getFileName()));
-            }
+            $configuration->addObjectResource($this);
 
             // save the resources
             $this->writeCacheFile($this->getCacheDir().'/'.$class.'.meta', serialize($configuration->getResources()));