function RulesDebugLog::build

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 119

Class

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

Namespace

Drupal\rules\Logger

Code

public function build() : array {
    $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
            // Need to filter out context keys that aren't recognized as
            // placeholders for t(), because Drupal core no longer supports these.
'#title' => $this->t($this->logs[$line]['message'], $this->filterContext($this->logs[$line]['context'])),
        ];
        // $line is modified inside renderHelper().
        $thisline = $line;
        $build[$thisline][] = $this->renderHelper($line);
        $line++;
    }
    return $build;
}