You are here

public function WardenCommands::check in Warden 8.2

Same name and namespace in other branches
  1. 8 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');
    $this
      ->output()
      ->writeln(dt('URL: :url', [
      ':url' => $warden
        ->getWardenUrl(),
    ]));
    if ($warden
      ->hasBasicAuthentication()) {
      $this
        ->output()
        ->writeln(dt('HTTP Username: :username', [
        ':username' => $warden
          ->getUsername(),
      ]));
      $this
        ->output()
        ->writeln(dt('HTTP Password: :password', [
        ':password' => $warden
          ->getPassword(),
      ]));
    }
    if ($warden
      ->hasCertificatePath()) {
      $this
        ->output()
        ->writeln(dt('Certificate file: :path', [
        ':path' => $warden
          ->getCertificatePath(),
      ]));
    }
    $key = $warden
      ->getPublicKey();
    $this
      ->output()
      ->writeln(dt('Going to check connection to Warden server by retrieving the public key ...'));
    $this
      ->output()
      ->writeln($key);
  } catch (Exception $e) {
    throw new \Exception($e
      ->getMessage());
  }
}