public function WardenCommands::check in Warden 3.x
Same name and namespace in other branches
- 8.2 src/Commands/WardenCommands.php \Drupal\warden\Commands\WardenCommands::check()
- 8 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\CommandsCode
public function check() {
  try {
    $warden = \Drupal::service('warden.manager');
    $this->logger
      ->log('ok', dt('URL: :url', [
      ':url' => $warden
        ->getWardenUrl(),
    ]));
    if ($warden
      ->hasBasicAuthentication()) {
      $this->logger
        ->log('ok', dt('HTTP Username: :username', [
        ':username' => $warden
          ->getUsername(),
      ]));
      $this->logger
        ->log('ok', dt('HTTP Password: :password', [
        ':password' => $warden
          ->getPassword(),
      ]));
    }
    if ($warden
      ->hasCertificatePath()) {
      $this->logger
        ->log('ok', dt('Certificate file: :path', [
        ':path' => $warden
          ->getCertificatePath(),
      ]));
    }
    $key = $warden
      ->getPublicKey();
    $this->logger
      ->log('ok', dt('Going to check connection to Warden server by retrieving the public key ...'));
    $this->logger
      ->log('ok', $key);
  } catch (Exception $e) {
    $this->logger
      ->error('ok', $e
      ->getMessage());
  }
}