/** * Mirrors a directory to another. * * @param string $originDir The origin directory * @param string $targetDir The target directory * @param sfFinder $finder An sfFinder instance * @param array $options An array of options (see copy()) */ public function mirror($originDir, $targetDir, nbFileFinder $finder, $options = array()) { $overwrite = isset($options['overwrite']) ? $options['overwrite'] : false; foreach ($finder->relative()->in($originDir) as $file) { if (is_dir($originDir . DIRECTORY_SEPARATOR . $file)) { $this->mkdir($targetDir . DIRECTORY_SEPARATOR . $file); } else { if (is_file($originDir . DIRECTORY_SEPARATOR . $file)) { $this->copy($originDir . DIRECTORY_SEPARATOR . $file, $targetDir . DIRECTORY_SEPARATOR . $file, $overwrite); } else { if (is_link($originDir . DIRECTORY_SEPARATOR . $file)) { $this->symlink($originDir . DIRECTORY_SEPARATOR . $file, $targetDir . DIRECTORY_SEPARATOR . $file); } else { throw new Exception(sprintf('Unable to guess "%s" file type.', $file)); } } } } }