You are here

function drush_domain_list in Domain Access 8

Same name and namespace in other branches
  1. 6.2 domain.drush.inc \drush_domain_list()
  2. 7.3 domain.drush.inc \drush_domain_list()
  3. 7.2 domain.drush.inc \drush_domain_list()

Shows the domain list.

File

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

Code

function drush_domain_list() {
  $domains = \Drupal::entityTypeManager()
    ->getStorage('domain')
    ->loadMultipleSorted(NULL, TRUE);
  if (empty($domains)) {
    drush_print(dt('No domains have been created. Use drush domain-add to create one.'));
    return;
  }
  $header = [
    'weight' => dt('Weight'),
    'name' => dt('Name'),
    'hostname' => dt('Hostname'),
    'scheme' => dt('Scheme'),
    'status' => dt('Status'),
    'is_default' => dt('Default'),
    'domain_id' => dt('Domain Id'),
    'id' => dt('Machine name'),
  ];
  $rows = [
    array_values($header),
  ];
  foreach ($domains as $domain) {
    $row = [];
    foreach ($header as $key => $name) {
      $row[] = Html::escape($domain
        ->get($key));
    }
    $rows[] = $row;
  }
  drush_print_table($rows, TRUE);
}