Example #1
0
File: pantr.php Project: pago/pantr
 public static function mirror($arg, $origin_dir, $target_dir, $isSilent = false, $options = array())
 {
     $files = pantr::_getFinderFromArg($arg, $origin_dir, true);
     // switch silent <-> options
     if (is_array($isSilent)) {
         $options = $isSilent;
         $isSilent = false;
     }
     if ($isSilent) {
         pantr::writeAction('mirror', $origin_dir . ' -> ' . $target_dir);
         pantr::beginSilent();
     }
     foreach ($files as $file) {
         if (is_dir($origin_dir . DIRECTORY_SEPARATOR . $file)) {
             pantr::mkdirs($target_dir . DIRECTORY_SEPARATOR . $file);
         } else {
             if (is_file($origin_dir . DIRECTORY_SEPARATOR . $file)) {
                 pantr::copy($origin_dir . DIRECTORY_SEPARATOR . $file, $target_dir . DIRECTORY_SEPARATOR . $file, $options);
             } else {
                 if (is_link($origin_dir . DIRECTORY_SEPARATOR . $file)) {
                     pantr::symlink($origin_dir . DIRECTORY_SEPARATOR . $file, $target_dir . DIRECTORY_SEPARATOR . $file);
                 } else {
                     throw new \Exception(sprintf('Unable to determine "%s" type', $file));
                 }
             }
         }
     }
     if ($isSilent) {
         pantr::endSilent();
     }
 }