You are here

public function DrupalEncrypt::configSchema in Backup and Migrate 5.0.x

Get a default (blank) schema.

Parameters

array $params: The parameters including:

  • operation - The operation being performed, will be one of:

    • 'backup': Configuration needed during a backup operation
    • 'restore': Configuration needed during a restore
    • 'initialize': Core configuration always needed by this item.

Return value

array

Overrides ConfigurableTrait::configSchema

File

src/Drupal/Filter/DrupalEncrypt.php, line 25

Class

DrupalEncrypt
@package Drupal\backup_migrate\Drupal\Filter

Namespace

Drupal\backup_migrate\Drupal\Filter

Code

public function configSchema(array $params = []) {
  $schema = [];

  // Backup configuration.
  if ($params['operation'] == 'backup' || $params['operation'] == 'restore') {
    if (class_exists('\\Defuse\\Crypto\\File')) {
      $schema['groups']['encrypt'] = [
        'title' => 'Backup Encryption',
      ];
      $schema['fields']['encrypt'] = [
        'group' => 'encrypt',
        'type' => 'boolean',
        'title' => $params['operation'] == 'backup' ? $this
          ->t('Encrypt File') : $this
          ->t('Decrypt file'),
        'description' => $this
          ->t('Password for encrypting / decrypting the file'),
      ];
      $schema['fields']['encrypt_password'] = [
        'group' => 'encrypt',
        'type' => 'password',
        'title' => $params['operation'] == 'backup' ? $this
          ->t('Encryption Password') : $this
          ->t('Decryption Password'),
      ];
    }
    else {
      \Drupal::messenger()
        ->addMessage(t('In order to encrypt backup files, please install the Defuse PHP-encryption library via Composer with the following command: <code>composer require defuse/php-encryption</code>. See the <a href="@docs">Defuse PHP Encryption Documentation Page</a> for more information.', array(
        '@docs' => 'https://www.drupal.org/node/3185484',
      )), 'status');
    }
  }
  return $schema;
}