本文整理汇总了PHP中IOHelper::copyFolder方法的典型用法代码示例。如果您正苦于以下问题:PHP IOHelper::copyFolder方法的具体用法?PHP IOHelper::copyFolder怎么用?PHP IOHelper::copyFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOHelper
的用法示例。
在下文中一共展示了IOHelper::copyFolder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copy
/**
* @param $destination
* @return bool
*/
public function copy($destination)
{
if (!IOHelper::copyFolder($this->getRealPath(), $destination)) {
return false;
}
return true;
}
示例2: _backupFiles
/**
* Attempt to backup each of the update manifest files by copying them to a file with the same name with a .bak
* extension. If there is an exception thrown, we attempt to roll back all of the changes.
*
* @param string $unzipFolder
* @param string $handle
*
* @return bool
*/
private function _backupFiles($unzipFolder, $handle)
{
$manifestData = UpdateHelper::getManifestData($unzipFolder, $handle);
try {
foreach ($manifestData as $row) {
if (UpdateHelper::isManifestVersionInfoLine($row)) {
continue;
}
// No need to back up migration files.
if (UpdateHelper::isManifestMigrationLine($row)) {
continue;
}
$rowData = explode(';', $row);
$filePath = IOHelper::normalizePathSeparators(($handle == 'craft' ? craft()->path->getAppPath() : craft()->path->getPluginsPath() . $handle . '/') . $rowData[0]);
// It's a folder
if (UpdateHelper::isManifestLineAFolder($filePath)) {
$folderPath = UpdateHelper::cleanManifestFolderLine($filePath);
if (IOHelper::folderExists($folderPath)) {
Craft::log('Backing up folder ' . $folderPath, LogLevel::Info, true);
IOHelper::createFolder($folderPath . '.bak');
IOHelper::copyFolder($folderPath . '/', $folderPath . '.bak/');
}
} else {
// If the file doesn't exist, it's probably a new file.
if (IOHelper::fileExists($filePath)) {
Craft::log('Backing up file ' . $filePath, LogLevel::Info, true);
IOHelper::copyFile($filePath, $filePath . '.bak');
}
}
}
} catch (\Exception $e) {
Craft::log('Error updating files: ' . $e->getMessage(), LogLevel::Error);
UpdateHelper::rollBackFileChanges($manifestData, $handle);
return false;
}
return true;
}
示例3: doFileUpdate
/**
* @param $manifestData
* @param $sourceTempFolder
* @param $handle
*
* @return bool
*/
public static function doFileUpdate($manifestData, $sourceTempFolder, $handle)
{
if ($handle == 'craft') {
$destDirectory = craft()->path->getAppPath();
$sourceFileDirectory = 'app/';
} else {
$destDirectory = craft()->path->getPluginsPath() . $handle . '/';
$sourceFileDirectory = '';
}
try {
foreach ($manifestData as $row) {
if (static::isManifestVersionInfoLine($row)) {
continue;
}
$folder = false;
$rowData = explode(';', $row);
if (static::isManifestLineAFolder($rowData[0])) {
$folder = true;
$tempPath = static::cleanManifestFolderLine($rowData[0]);
} else {
$tempPath = $rowData[0];
}
$destFile = IOHelper::normalizePathSeparators($destDirectory . $tempPath);
$sourceFile = IOHelper::getRealPath(IOHelper::normalizePathSeparators($sourceTempFolder . '/' . $sourceFileDirectory . $tempPath));
switch (trim($rowData[1])) {
// update the file
case PatchManifestFileAction::Add:
if ($folder) {
Craft::log('Updating folder: ' . $destFile, LogLevel::Info, true);
$tempFolder = rtrim($destFile, '/') . StringHelper::UUID() . '/';
$tempTempFolder = rtrim($destFile, '/') . '-tmp/';
IOHelper::createFolder($tempFolder);
IOHelper::copyFolder($sourceFile, $tempFolder);
IOHelper::rename($destFile, $tempTempFolder);
IOHelper::rename($tempFolder, $destFile);
IOHelper::clearFolder($tempTempFolder);
IOHelper::deleteFolder($tempTempFolder);
} else {
Craft::log('Updating file: ' . $destFile, LogLevel::Info, true);
IOHelper::copyFile($sourceFile, $destFile);
}
break;
}
}
} catch (\Exception $e) {
Craft::log('Error updating files: ' . $e->getMessage(), LogLevel::Error);
UpdateHelper::rollBackFileChanges($manifestData, $handle);
return false;
}
return true;
}
示例4: _copyTemplates
/**
* Copies template files to templates folder
*
* @return null
*/
private function _copyTemplates()
{
$instaBlogFolder = trim(realpath(dirname(__FILE__)), 'services') . 'resources/_templates/';
$craftTemplateFolder = realpath(CRAFT_TEMPLATES_PATH);
$instaBlogTargetFolder = $craftTemplateFolder . '/blog/';
Craft::log('Creating blog folder in templates directory.', LogLevel::Info, true, '_copyTemplates', 'InstaBlog');
IOHelper::createFolder($instaBlogTargetFolder, 0755, true);
Craft::log('Copying InstaBlog templates to templates/blog directory.', LogLevel::Info, true, '_copyTemplates', 'InstaBlog');
if (IOHelper::copyFolder($instaBlogFolder, $instaBlogTargetFolder, true)) {
Craft::log($instaBlogFolder . ' copied to ' . $instaBlogTargetFolder . ' successfully.', LogLevel::Info, true, '_copyTemplates', 'InstaBlog');
} else {
Craft::log('Failed copying ' . $instaBlogFolder . ' to ' . $instaBlogTargetFolder, LogLevel::Error, true, '_copyTemplates', 'InstaBlog');
}
}