protected function InPlaceUpdate::doBackup in Automatic Updates 8
Execute file backup.
Parameters
string $file: The file to backup.
string $project_root: The project root directory.
Return value
bool Return TRUE if backup succeeds, FALSE otherwise.
1 call to InPlaceUpdate::doBackup()
- InPlaceUpdate::backup in src/
Services/ InPlaceUpdate.php - Backup before an update.
File
- src/
Services/ InPlaceUpdate.php, line 431
Class
- InPlaceUpdate
- Class to apply in-place updates.
Namespace
Drupal\automatic_updates\ServicesCode
protected function doBackup($file, $project_root) {
$directory = $this->backup . dirname($file);
if (!file_exists($directory) && !$this->fileSystem
->mkdir($directory, NULL, TRUE)) {
return FALSE;
}
$project_real_path = $this
->getProjectRealPath($file, $project_root);
if (file_exists($project_real_path) && !is_dir($project_real_path)) {
try {
$this->fileSystem
->copy($project_real_path, $this->backup . $file, FileSystemInterface::EXISTS_REPLACE);
$this->logger
->info('"@file" was backed up in preparation for an update.', [
'@file' => $project_real_path,
]);
} catch (FileException $exception) {
return FALSE;
}
}
return TRUE;
}