1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-23 23:02:58 +02:00

Add PagefilesManager->importFiles() and PagefilesManager->replaceFiles() methods

This commit is contained in:
Ryan Cramer
2018-09-21 13:29:47 -04:00
parent f0cc6f1134
commit 9a7e5d5bd3

View File

@@ -230,6 +230,40 @@ class PagefilesManager extends Wire {
return $this->_copyFiles($this->path(), $toPath); return $this->_copyFiles($this->path(), $toPath);
} }
/**
* Copy/import files from given path into the pages files directory
*
* #pw-group-manipulation
*
* @param string $fromPath Path to copy/import files from.
* @param bool $move Move files into directory rather than copy?
* @return int Number of files/directories copied.
* @since 3.0.114
*
*/
public function importFiles($fromPath, $move = false) {
return $this->_copyFiles($fromPath, $this->path(), $move);
}
/**
* Replace all pages files with those from given path
*
* #pw-group-manipulation
*
* @param string $fromPath
* @param bool $move Move files to destination rather than copy? (default=false)
* @return int Number of files/directories copied.
* @throws WireException if given a path that does not exist.
* @since 3.0.114
*
*
*/
public function replaceFiles($fromPath, $move = false) {
if(!is_dir($fromPath)) throw new WireException("Path does not exist: $fromPath");
$this->emptyPath();
return $this->_copyFiles($fromPath, $this->path(), $move);
}
/** /**
* Recursively move all files managed by this PagefilesManager into a new path. * Recursively move all files managed by this PagefilesManager into a new path.
* *