Permalink
Browse files

Add PagefilesManager->importFiles() and PagefilesManager->replaceFile…

…s() methods
  • Loading branch information...
ryancramerdesign committed Sep 21, 2018
1 parent f0cc6f1 commit 9a7e5d5bd37ed683920ea0384ebb2e6eb60802ce
Showing with 34 additions and 0 deletions.
  1. +34 −0 wire/core/PagefilesManager.php
@@ -230,6 +230,40 @@ public function copyFiles($toPath) {
return $this->_copyFiles($this->path(), $toPath);
}
/**
* Copy/import files from given path into the page’s 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 page’s 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.
*

0 comments on commit 9a7e5d5

Please sign in to comment.