Kraken\Filesystem\FilesystemManager::copyDir PHP Метод

copyDir() публичный Метод

public copyDir ( $source, $destination )
    public function copyDir($source, $destination)
    {
        list($sourcePrefix, $sourcePath) = $this->filterPrefix($source);
        list($destPrefix, $destPath) = $this->filterPrefix($destination);
        if (($sourceFs = $this->getFilesystem($sourcePrefix)) === null || ($destFs = $this->getFilesystem($destPrefix)) === null) {
            throw new WriteException("No filesystem saved under prefix [{$sourcePrefix}].");
        }
        if (!$sourceFs->exists($sourcePath) || !$sourceFs->isDir($sourcePath) || $destFs->exists($destPath)) {
            throw new WriteException("Could not copy {$source}.");
        }
        $filesList = $sourceFs->getContents($sourcePath, true);
        foreach ($filesList as $file) {
            $path = $file['path'];
            $dest = explode(DIRECTORY_SEPARATOR, $path, 2);
            $dest = $destPath . DIRECTORY_SEPARATOR . $dest[1];
            if ($file['type'] === Filesystem::TYPE_DIRECTORY) {
                $destFs->createDir($dest);
            } else {
                if ($file['type'] === Filesystem::TYPE_FILE) {
                    $destFs->createFile($dest, $sourceFs->read($path));
                }
            }
        }
    }