You are here

public function EncryptCommands::validateProfile in Encrypt 8.3

Validates the encryption profile to check if all dependencies are met.

@command encrypt:validate-profile @usage drush encrypt:validate-profile profile_name Validates the given encryption profile. @aliases evp

Parameters

string $encryption_profile_name: The machine name of the encryption profile to use.

Return value

array A list of errors.

Throws

\Exception

File

src/Commands/EncryptCommands.php, line 119

Class

EncryptCommands
Class EncryptCommands.

Namespace

Drupal\encrypt\Commands

Code

public function validateProfile($encryption_profile_name) {
  $output = [];
  $encryption_profile = EncryptionProfile::load($encryption_profile_name);
  if (!$encryption_profile) {
    throw new \Exception('', dt('Encryption profile "@name" could not be loaded.', [
      '@name' => $encryption_profile_name,
    ]));
  }
  $errors = $encryption_profile
    ->validate();
  if ($errors) {
    foreach ($errors as $error_msg) {
      $output[] = [
        'error' => $error_msg,
      ];
    }
    return $output;
  }
  $this
    ->logger()
    ->notice('Encryption profile validates successfully.');
}