You are here

function domain_drush_check_response in Domain Access 8

Runs a check to ensure that the domain is responsive.

Parameters

Drupal\domain\DomainInterface $domain: A domain entity.

Return value

string An error message if the domain url does not validate. Else empty.

2 calls to domain_drush_check_response()
domain_drush_create in domain/domain.drush.inc
Creates a domain record.
drush_domain_default in domain/domain.drush.inc
Sets the default domain id.

File

domain/domain.drush.inc, line 387
Drush commands for Domain Access.

Code

function domain_drush_check_response(DomainInterface $domain) {

  // Check the domain response. First, clear the path value.
  if ($domain->validate_url) {
    $domain
      ->setPath();
    try {
      $response = $domain
        ->getResponse();
    } catch (RequestException $e) {
      watchdog_exception('domain', $e);

      // File a general server failure.
      $domain
        ->setResponse(500);
    }

    // If validate_url is set, then we must receive a 200 response.
    if ($domain
      ->getResponse() != 200) {
      if (empty($response)) {
        $response = 500;
      }
      return dt('The server request to @url returned a @response response. To proceed, disable the test of the server response by leaving off the --validate flag.', [
        '@url' => $domain
          ->getPath(),
        '@response' => $response,
      ]);
    }
  }
}