You are here

public function DomainCommands::test in Domain Access 8

Tests domains for proper response.

If run from a subfolder, you must specify the --uri.

@usage drush domain-test @usage drush domain-test example.com

@command domain:test @aliases domain-test

@field-labels id: Machine name url: URL response: HTTP Response @default-fields id,url,response

Parameters

string $domain_id: The machine name or hostname of the domain to make default.

Return value

\Consolidation\OutputFormatters\StructuredData\RowsOfFields Tabled output.

Throws

\Drupal\domain\Commands\DomainCommandException

File

domain/src/Commands/DomainCommands.php, line 580

Class

DomainCommands
Drush commands for the domain module.

Namespace

Drupal\domain\Commands

Code

public function test($domain_id = NULL) {
  if (is_null($domain_id)) {
    $domains = $this
      ->domainStorage()
      ->loadMultipleSorted();
  }
  else {
    if ($domain = $this
      ->getDomainFromArgument($domain_id)) {
      $domains = [
        $domain,
      ];
    }
    else {
      throw new DomainCommandException(dt('Domain @domain not found.', [
        '@domain' => $options['domain'],
      ]));
    }
  }
  $rows = [];
  foreach ($domains as $domain) {
    $rows[] = [
      'id' => $domain
        ->id(),
      'url' => $domain
        ->getPath(),
      'response' => $domain
        ->getResponse(),
    ];
  }
  return new RowsOfFields($rows);
}