You are here

public function RulesDebugLog::build in Rules 8.3

Assembles the entire log into a render array.

Return value

array A Drupal render array.

1 call to RulesDebugLog::build()
RulesDebugLog::render in src/Logger/RulesDebugLog.php
Renders the whole log.

File

src/Logger/RulesDebugLog.php, line 117

Class

RulesDebugLog
Logger that stores Rules debug logs with the session service.

Namespace

Drupal\rules\Logger

Code

public function build() {
  $this->logs = $this
    ->getLogs();
  if (count($this->logs) == 0) {

    // Nothing to render.
    return [];
  }

  // Container for all log entries.
  $build = [
    '#type' => 'details',
    // @codingStandardsIgnoreStart
    '#title' => $this
      ->t('Rules evaluation log') . '<span class="rules-debug-open-all">-Open all-</span>',
    // @codingStandardsIgnoreEnd
    '#attributes' => [
      'class' => [
        'rules-debug-log',
      ],
    ],
  ];
  $line = 0;
  while (isset($this->logs[$line])) {

    // Each event is in its own 'details' wrapper so the details of
    // evaluation may be opened or closed.
    $build[$line] = [
      '#type' => 'details',
      // @codingStandardsIgnoreStart
      '#title' => $this
        ->t($this->logs[$line]['message'], $this->logs[$line]['context']),
    ];

    // $line is modified inside renderHelper().
    $thisline = $line;
    $build[$thisline][] = $this
      ->renderHelper($line);
    $line++;
  }
  return $build;
}