class DrupalSiteArchiveSource in Backup and Migrate 8.4
Class DrupalSiteArchiveSource.
@package BackupMigrate\Drupal\Source
Hierarchy
- class \BackupMigrate\Core\Plugin\PluginBase implements ConfigurableInterface, PluginInterface uses ConfigurableTrait
- class \BackupMigrate\Core\Source\FileDirectorySource implements FileProcessorInterface, PluginCallerInterface, SourceInterface uses FileProcessorTrait, PluginCallerTrait
- class \BackupMigrate\Drupal\Source\DrupalSiteArchiveSource
- class \BackupMigrate\Core\Source\FileDirectorySource implements FileProcessorInterface, PluginCallerInterface, SourceInterface uses FileProcessorTrait, PluginCallerTrait
Expanded class hierarchy of DrupalSiteArchiveSource
1 file declares its use of DrupalSiteArchiveSource
- EntireSiteSourcePlugin.php in src/
Plugin/ BackupMigrateSource/ EntireSiteSourcePlugin.php
File
- src/
Source/ DrupalSiteArchiveSource.php, line 20
Namespace
BackupMigrate\Drupal\SourceView source
class DrupalSiteArchiveSource extends FileDirectorySource {
/**
* @var SourceInterface
*/
protected $db_source;
/**
* @param ConfigInterface|array $init
* @param \BackupMigrate\Core\Source\SourceInterface $db
* @param \BackupMigrate\Core\Source\SourceInterface $code
*/
public function __construct($init = [], SourceInterface $db) {
parent::__construct($init);
$this->db_source = $db;
}
/**
* Get a list if files to be backed up from the given directory. Do not
* include files that match the 'exclude_filepaths' setting.
*
* @param string $dir The name of the directory to list.
*
* @return array
*
* @throws \BackupMigrate\Core\Exception\BackupMigrateException
* @throws \BackupMigrate\Core\Exception\IgnorableException
*
* @internal param $directory
*/
protected function getFilesToBackup($dir) {
$files = [];
// Add the database dump.
// @TODO: realpath contains the wrong filename and the PEAR archiver cannot rename files.
$db = $this
->getDbSource()
->exportToFile();
$files['database.sql'] = $db
->realpath();
// Add the manifest file.
$manifest = $this
->getManifestFile();
$files['MANIFEST.ini'] = $manifest
->realpath();
// Get all the files in the site.
foreach (parent::getFilesToBackup($dir) as $new => $real) {
// Prepend 'docroot' onto the local path.
$files['docroot/' . $new] = $real;
}
return $files;
}
/**
* Import to this source from the given backup file. This is the main restore
* function for this source.
*
* @param BackupFileReadableInterface $file
* The file to read the backup from. It will not be opened for reading
*
* @return bool|void
*/
public function importFromFile(BackupFileReadableInterface $file) {
// TODO: Implement importFromFile() method.
}
/**
* Get a file which contains the file.
*
* @return \BackupMigrate\Core\File\BackupFileWritableInterface
*/
protected function getManifestFile() {
$out = $this
->getTempFileManager()
->create('ini');
$info = [
'Global' => [
'datestamp' => time(),
"formatversion" => "2011-07-02",
"generator" => "Backup and Migrate (http://drupal.org/project/backup_migrate)",
"generatorversion" => BACKUP_MIGRATE_MODULE_VERSION,
],
'Site 0' => [
'version' => \Drupal::VERSION,
'name' => "Example.com",
'docroot' => "docroot",
'sitedir' => "docroot/sites/default",
'database-file-default' => "database.sql",
'database-file-driver' => "mysql",
'files-private' => "docroot/sites/default/private",
'files-public' => "docroot/sites/default/files",
],
];
$out
->writeAll($this
->arrayToINI($info));
return $out;
}
/**
* Translate a 2d array to an INI string which can be written to a file.
*
* @param array $info
* The array to convert. Must be an array of sections each of which is an array of field/value pairs.
*
* @return string
* The data in INI format.
*/
private function arrayToINI($info) {
$content = "";
foreach ($info as $section => $data) {
$content .= '[' . $section . ']' . "\n";
foreach ($data as $key => $val) {
$content .= $key . " = \"" . $val . "\"\n";
}
$content .= "\n";
}
return $content;
}
/**
* @return SourceInterface
*/
public function getDbSource() {
return $this->db_source;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurableTrait:: |
protected | property | The object's configuration object. | |
ConfigurableTrait:: |
protected | property | The initial configuration. These configuration options can be overriden by the config options but will not be overwritten. If the object is re-configured after construction any missing configuration options will revert to these values. | |
ConfigurableTrait:: |
public | function | Get a specific value from the configuration. | |
ConfigurableTrait:: |
public | function | Get the configuration object for this item. | |
ConfigurableTrait:: |
public | function | Get any validation errors in the config. | |
ConfigurableTrait:: |
public | function | Set the configuration for all plugins. | 1 |
DrupalSiteArchiveSource:: |
protected | property | ||
DrupalSiteArchiveSource:: |
private | function | Translate a 2d array to an INI string which can be written to a file. | |
DrupalSiteArchiveSource:: |
public | function | ||
DrupalSiteArchiveSource:: |
protected | function |
Get a list if files to be backed up from the given directory. Do not
include files that match the 'exclude_filepaths' setting. Overrides FileDirectorySource:: |
|
DrupalSiteArchiveSource:: |
protected | function | Get a file which contains the file. | |
DrupalSiteArchiveSource:: |
public | function |
Import to this source from the given backup file. This is the main restore
function for this source. Overrides FileDirectorySource:: |
|
DrupalSiteArchiveSource:: |
public | function |
Overrides ConfigurableTrait:: |
|
FileDirectorySource:: |
private | property | ||
FileDirectorySource:: |
private | property | ||
FileDirectorySource:: |
public | function |
Get the default values for the plugin. Overrides ConfigurableTrait:: |
1 |
FileDirectorySource:: |
public | function |
Get a definition for user-configurable settings. Overrides ConfigurableTrait:: |
|
FileDirectorySource:: |
public | function |
Export this source to the given temp file. This should be the main
back up function for this source. Overrides SourceInterface:: |
|
FileDirectorySource:: |
public | function | ||
FileDirectorySource:: |
public | function | ||
FileDirectorySource:: |
public | function | ||
FileDirectorySource:: |
public | function | ||
FileDirectorySource:: |
public | function |
Get a list of supported operations and their weight. Overrides PluginBase:: |
|
FileDirectorySource:: |
protected | function | @internal param string $dir | |
FileProcessorTrait:: |
protected | property | ||
FileProcessorTrait:: |
public | function | Provide the file mime for the given file extension if known. | |
FileProcessorTrait:: |
public | function | Get the temp file manager. | |
FileProcessorTrait:: |
public | function | Inject the temp file manager. | |
PluginBase:: |
public | function |
What is the weight of the given operation for this plugin. Overrides PluginInterface:: |
|
PluginBase:: |
public | function |
Does this plugin implement the given operation. Overrides PluginInterface:: |
|
PluginCallerTrait:: |
protected | property | ||
PluginCallerTrait:: |
public | function | Get the plugin manager. | |
PluginCallerTrait:: |
public | function | Inject the plugin manager. | |
TranslatableTrait:: |
protected | property | ||
TranslatableTrait:: |
public | function | ||
TranslatableTrait:: |
public | function | Translate the given string if there is a translator service available. |