فهرست منبع

Update code with latest Finder changes

Victor Berchet 14 سال پیش
والد
کامیت
1d7f8120e0

+ 5 - 18
src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php

@@ -79,8 +79,9 @@ class TemplatePathsCacheWarmer extends CacheWarmer
 
             $finder = new Finder();
             foreach ($finder->files()->followLinks()->in($dir) as $file) {
-                if (false !== $template = $this->parseTemplateName($file, $prefix.'/', $bundle->getName())) {
-
+                $template = $this->parser->parseFromFilename($file->getRelativePathname());
+                if (false !== $template) {
+                    $template->set('bundle', $name);
                     $templates[$template->getSignature()] = $this->locator->locate($template->getPath(), $this->rootDir);
                 }
             }
@@ -89,7 +90,8 @@ class TemplatePathsCacheWarmer extends CacheWarmer
         if (is_dir($this->rootDir)) {
             $finder = new Finder();
             foreach ($finder->files()->followLinks()->in($this->rootDir) as $file) {
-                if (false !== $template = $this->parseTemplateName($file, strtr($this->rootDir, '\\', '/').'/')) {
+                $template = $this->parser->parseFromFilename($file->getRelativePathname());
+                if (false !== $template) {
                     $templates[$template->getSignature()] = $file->getRealPath();
                 }
             }
@@ -97,19 +99,4 @@ class TemplatePathsCacheWarmer extends CacheWarmer
 
         return  $templates;
     }
-
-    protected function parseTemplateName($file, $prefix, $bundle = '')
-    {      
-        $prefix = strtr($prefix, '\\', '/');
-        $path = strtr($file->getPathname(), '\\', '/');
-
-        list(, $file) = explode($prefix, $path, 2);
-
-        $template = $this->parser->parseFromFilename($file);
-        if (false !== $template) {
-            $template->set('bundle', $bundle);
-        }
-
-        return $template;
-    }
 }

+ 1 - 1
src/Symfony/Component/HttpKernel/Bundle/Bundle.php

@@ -149,7 +149,7 @@ abstract class Bundle extends ContainerAware implements BundleInterface
 
         $prefix = $this->getNamespace().'\\Command';
         foreach ($finder as $file) {
-            $r = new \ReflectionClass($prefix.strtr($file->getPath(), array($dir => '', '/' => '\\')).'\\'.$file->getBasename('.php'));
+            $r = new \ReflectionClass($prefix.strtr($file->getRelativePath(), '/', '\\').'\\'.$file->getBasename('.php'));
             if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract()) {
                 $application->add($r->newInstance());
             }

+ 1 - 2
src/Symfony/Component/HttpKernel/bootstrap.php

@@ -300,7 +300,7 @@ abstract class Bundle extends ContainerAware implements BundleInterface
         $finder->files()->name('*Command.php')->in($dir);
         $prefix = $this->getNamespace().'\\Command';
         foreach ($finder as $file) {
-            $r = new \ReflectionClass($prefix.strtr($file->getPath(), array($dir => '', '/' => '\\')).'\\'.$file->getBasename('.php'));
+            $r = new \ReflectionClass($prefix.strtr($file->getRelativePath(), '/', '\\').'\\'.$file->getBasename('.php'));
             if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract()) {
                 $application->add($r->newInstance());
             }
@@ -865,7 +865,6 @@ class FileBag extends ParameterBag
     private $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type');
     public function __construct(array $parameters = array())
     {
-                        parent::__construct();
         $this->replace($parameters);
     }
     public function replace(array $files = array())

+ 4 - 3
src/Symfony/Component/HttpKernel/bootstrap_cache.php

@@ -1099,7 +1099,6 @@ class FileBag extends ParameterBag
     private $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type');
     public function __construct(array $parameters = array())
     {
-                        parent::__construct();
         $this->replace($parameters);
     }
     public function replace(array $files = array())
@@ -1939,8 +1938,10 @@ class ResponseHeaderBag extends HeaderBag
     protected $computedCacheControl = array();
     public function __construct(array $headers = array())
     {
-                        parent::__construct();
-        $this->replace($headers);
+        parent::__construct($headers);
+        if (!isset($this->headers['cache-control'])) {
+            $this->set('cache-control', '');
+        }
     }
     public function replace(array $headers = array())
     {

+ 2 - 2
src/Symfony/Component/Security/Acl/Resources/bin/generateSql.php

@@ -25,12 +25,12 @@ $schema = new Schema(array(
     'sid_table_name'           => 'acl_security_identities',
 ));
 
-$reflection = new ReflectionClass('Doctrine\DBAL\Platforms\AbstractPlatform');
+$reflection = new ReflectionClass('Doctrine\\DBAL\\Platforms\\AbstractPlatform');
 $finder = new Finder();
 $finder->name('*.php')->in(dirname($reflection->getFileName()));
 foreach ($finder as $file) {
     require_once $file->getPathName();
-    $className = sprintf('Doctrine\DBAL\Platforms\%s', basename($file->getFilename(), '.php'));
+    $className = 'Doctrine\\DBAL\\Platforms\\' . $file->getBasename('.php');
 
     $reflection = new ReflectionClass($className);
     if ($reflection->isAbstract()) {