class DrupalUtils in Backup and Migrate 5.0.x
@package Drupal\backup_migrate\Drupal\Filter
Hierarchy
- class \Drupal\backup_migrate\Core\Plugin\PluginBase implements ConfigurableInterface, PluginInterface uses ConfigurableTrait
- class \Drupal\backup_migrate\Drupal\Filter\DrupalUtils
Expanded class hierarchy of DrupalUtils
1 file declares its use of DrupalUtils
- backup_migrate.module in ./
backup_migrate.module - Primary hook implementations for Backup Migrate.
File
- src/
Drupal/ Filter/ DrupalUtils.php, line 14
Namespace
Drupal\backup_migrate\Drupal\FilterView source
class DrupalUtils extends PluginBase {
/**
* Whether the site was put in maintenance mode before the operation.
*
* @var bool
*/
protected $maintenanceMode;
/**
* {@inheritdoc}
*/
public function configSchema(array $params = []) {
$schema = [];
// Backup configuration.
if ($params['operation'] == 'backup' || $params['operation'] == 'restore') {
$schema['groups']['advanced'] = [
'title' => 'Advanced Settings',
];
$schema['fields']['site_offline'] = [
'group' => 'advanced',
'type' => 'boolean',
'title' => $this
->t('Take site offline'),
'description' => $this
->t('Take the site offline during backup and show a maintenance message. Site will be taken back online once the backup is complete.'),
];
}
return $schema;
}
/**
* Get the default values for the plugin.
*
* @return \Drupal\backup_migrate\Core\Config\Config
*/
public function configDefaults() {
return new Config([
'disable_query_log' => TRUE,
'site_offline' => FALSE,
]);
}
/**
* Run before the backup/restore begins.
*/
public function setUp() {
$this
->takeSiteOffline();
}
/**
* Run after the operation is complete.
*/
public function tearDown() {
$this
->takeSiteOnline();
}
/**
* Take the site offline if we need to.
*/
protected function takeSiteOffline() {
// Take the site offline.
if ($this
->confGet('site_offline') && !\Drupal::state()
->get('system.maintenance_mode')) {
\Drupal::state()
->set('system.maintenance_mode', TRUE);
$this->maintenanceMode = TRUE;
}
}
/**
* Take the site online if it was taken offline for this operation.
*/
protected function takeSiteOnline() {
// Take the site online again.
if ($this->maintenanceMode) {
\Drupal::state()
->set('system.maintenance_mode', FALSE);
}
}
/**
* Perform actions before restoring the backup.
*
* This used to perform a file size check but it occurred *after* the file
* was uploaded and uncompressed, which was a complete waste of time.
*
* @todo Remove this.
*
* @param \Drupal\backup_migrate\Core\File\BackupFileReadableInterface $file
*
* @return \Drupal\backup_migrate\Core\File\BackupFileReadableInterface
*/
public function beforeRestore(BackupFileReadableInterface $file) {
return $file;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurableTrait:: |
protected | property | The object's configuration object. | |
ConfigurableTrait:: |
protected | property | The initial configuration. | |
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 |
ConfigurableTrait:: |
public | function | 2 | |
DrupalUtils:: |
protected | property | Whether the site was put in maintenance mode before the operation. | |
DrupalUtils:: |
public | function | Perform actions before restoring the backup. | |
DrupalUtils:: |
public | function |
Get the default values for the plugin. Overrides ConfigurableTrait:: |
|
DrupalUtils:: |
public | function |
Get a default (blank) schema. Overrides ConfigurableTrait:: |
|
DrupalUtils:: |
public | function | Run before the backup/restore begins. | |
DrupalUtils:: |
protected | function | Take the site offline if we need to. | |
DrupalUtils:: |
protected | function | Take the site online if it was taken offline for this operation. | |
DrupalUtils:: |
public | function | Run after the operation is complete. | |
PluginBase:: |
public | function |
What is the weight of the given operation for this plugin. Overrides PluginInterface:: |
|
PluginBase:: |
public | function |
Get a list of supported operations and their weight. Overrides PluginInterface:: |
8 |
PluginBase:: |
public | function |
Does this plugin implement the given operation. Overrides PluginInterface:: |
|
TranslatableTrait:: |
protected | property | ||
TranslatableTrait:: |
public | function | ||
TranslatableTrait:: |
public | function | Translate the given string if there is a translator service available. |