You are here

public function WardenCommands::check in Warden 8

Same name and namespace in other branches
  1. 8.2 src/Commands/WardenCommands.php \Drupal\warden\Commands\WardenCommands::check()
  2. 3.x src/Commands/WardenCommands.php \Drupal\warden\Commands\WardenCommands::check()

Test the connection to Warden by getting its public key

@command warden:check @aliases warden-check

File

src/Commands/WardenCommands.php, line 27

Class

WardenCommands
A Drush commandfile.

Namespace

Drupal\warden\Commands

Code

public function check() {
  try {
    $warden = \Drupal::service('warden.manager');
    drush_print(dt('URL: :url', [
      ':url' => $warden
        ->getWardenUrl(),
    ]));
    if ($warden
      ->hasBasicAuthentication()) {
      drush_print(dt('HTTP Username: :username', [
        ':username' => $warden
          ->getUsername(),
      ]));
      drush_print(dt('HTTP Password: :password', [
        ':password' => $warden
          ->getPassword(),
      ]));
    }
    if ($warden
      ->hasCertificatePath()) {
      drush_print(dt('Certificate file: :path', [
        ':path' => $warden
          ->getCertificatePath(),
      ]));
    }
    $key = $warden
      ->getPublicKey();
    drush_print(dt('Going to check connection to Warden server by retrieving the public key ...'));
    drush_print($key);
  } catch (Exception $e) {
    drush_set_error($e
      ->getMessage());
  }
}