Puli\Repository\FilesystemRepository::symlinkMirror PHP Method

symlinkMirror() private method

private symlinkMirror ( $origin, $target, array $dirsToKeep = [] )
$dirsToKeep array
    private function symlinkMirror($origin, $target, array $dirsToKeep = array())
    {
        $targetIsDir = is_dir($target);
        $forceDir = in_array($target, $dirsToKeep, true);
        // Merge directories
        if (is_dir($origin) && ($targetIsDir || $forceDir)) {
            if (is_link($target)) {
                $this->replaceLinkByCopy($target, $dirsToKeep);
            }
            $iterator = $this->getDirectoryIterator($origin);
            foreach ($iterator as $path) {
                $this->symlinkMirror($path, $target . '/' . basename($path), $dirsToKeep);
            }
            return;
        }
        // Replace target
        if (file_exists($target)) {
            $this->filesystem->remove($target);
        }
        // Try creating a relative link
        if ($this->relative && $this->trySymlink(Path::makeRelative($origin, Path::getDirectory($target)), $target)) {
            return;
        }
        // Try creating a absolute link
        if ($this->trySymlink($origin, $target)) {
            return;
        }
        // Fall back to copy
        if (is_dir($origin)) {
            $this->filesystem->mirror($origin, $target);
            return;
        }
        $this->filesystem->copy($origin, $target);
    }