You are here

public function DomainServerBlock::printArray in Domain Access 8

Prints array data for the server block.

Parameters

array $array: An array of data. Note that we support two levels of nesting.

Return value

string A suitable output string.

1 call to DomainServerBlock::printArray()
DomainServerBlock::build in domain/src/Plugin/Block/DomainServerBlock.php
Build the output.

File

domain/src/Plugin/Block/DomainServerBlock.php, line 122

Class

DomainServerBlock
Provides a server information block for a domain request.

Namespace

Drupal\domain\Plugin\Block

Code

public function printArray(array $array) {
  $items = [];
  foreach ($array as $key => $val) {
    if (!is_array($val)) {
      $value = Html::escape($val);
    }
    else {
      $list = [];
      foreach ($val as $k => $v) {
        $list[] = $this
          ->t('@key : @value', [
          '@key' => $k,
          '@value' => $v,
        ]);
      }
      $value = implode('<br />', $list);
    }
    $items[] = $this
      ->t('@key : @value', [
      '@key' => $key,
      '@value' => $value,
    ]);
  }
  $variables['domain_server'] = [
    '#theme' => 'item_list',
    '#items' => $items,
  ];
  return render($variables);
}