瀏覽代碼

[FoundationBundle] removed Finder dependency in Filesystem

Fabien Potencier 15 年之前
父節點
當前提交
99c33cadf0
共有 1 個文件被更改,包括 8 次插入10 次删除
  1. 8 10
      src/Symfony/Framework/FoundationBundle/Util/Filesystem.php

+ 8 - 10
src/Symfony/Framework/FoundationBundle/Util/Filesystem.php

@@ -2,8 +2,6 @@
 
 namespace Symfony\Framework\FoundationBundle\Util;
 
-use Symfony\Components\Finder\Finder;
-
 /*
  * This file is part of the Symfony framework.
  *
@@ -197,20 +195,20 @@ class Filesystem
     /**
      * Mirrors a directory to another.
      *
-     * @param string $originDir  The origin directory
-     * @param string $targetDir  The target directory
-     * @param Finder $finder     An Finder instance
-     * @param array  $options    An array of options (see copy())
+     * @param string $originDir      The origin directory
+     * @param string $targetDir      The target directory
+     * @param \Traversable $iterator A Traversable instance
+     * @param array  $options        An array of options (see copy())
      *
      * @throws \RuntimeException When file type is unknown
      */
-    public function mirror($originDir, $targetDir, Finder $finder = null, $options = array())
+    public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array())
     {
-        if (null === $finder) {
-            $finder = new Finder();
+        if (null === $iterator) {
+            $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
         }
 
-        foreach ($finder->in($originDir) as $file) {
+        foreach ($iterator as $file) {
             $target = $targetDir.DIRECTORY_SEPARATOR.str_replace(realpath($originDir), '', $file->getRealPath());
 
             if (is_dir($file)) {