Skip to content

Commit

Permalink
[WebBundle] fixed Filesystem::mirror to use the new Finder component
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Apr 21, 2010
1 parent 6060d01 commit e0456fb
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/Symfony/Framework/WebBundle/Util/Filesystem.php
Expand Up @@ -226,26 +226,28 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false)
*
* @throws \RuntimeException When file type is unknown
*/
public function mirror($originDir, $targetDir, $finder = null, $options = array())
public function mirror($originDir, $targetDir, Finder $finder = null, $options = array())
{
if (null === $finder)
{
$finder = Finder::type('any');
$finder = new Finder();
}

foreach ($finder->relative()->in($originDir) as $file)
foreach ($finder->in($originDir) as $file)
{
if (is_dir($originDir.DIRECTORY_SEPARATOR.$file))
$target = $targetDir.DIRECTORY_SEPARATOR.str_replace(realpath($originDir), '', $file->getRealPath());

if (is_dir($file))
{
$this->mkdirs($targetDir.DIRECTORY_SEPARATOR.$file);
$this->mkdirs($target);
}
else if (is_file($originDir.DIRECTORY_SEPARATOR.$file))
else if (is_file($file))
{
$this->copy($originDir.DIRECTORY_SEPARATOR.$file, $targetDir.DIRECTORY_SEPARATOR.$file, $options);
$this->copy($file, $target, $options);
}
else if (is_link($originDir.DIRECTORY_SEPARATOR.$file))
else if (is_link($file))
{
$this->symlink($originDir.DIRECTORY_SEPARATOR.$file, $targetDir.DIRECTORY_SEPARATOR.$file);
$this->symlink($file, $target);
}
else
{
Expand Down

0 comments on commit e0456fb

Please sign in to comment.