function RulesDebugLog::renderHelper
Renders the log of one event invocation.
Called recursively, consuming all the log lines for this event.
Parameters
int $line: The line number of the log, starting at 0.
Return value
array A render array.
1 call to RulesDebugLog::renderHelper()
- RulesDebugLog::build in src/
Logger/ RulesDebugLog.php - Assembles the entire log into a render array.
File
-
src/
Logger/ RulesDebugLog.php, line 170
Class
- RulesDebugLog
- Logger that stores Rules debug logs with the session service.
Namespace
Drupal\rules\LoggerCode
protected function renderHelper(int &$line = 0) : array {
$build = [];
$startTime = $this->logs[$line]['timestamp'];
while ($line < count($this->logs)) {
if ($build && !empty($this->logs[$line]['scope'])) {
// This next entry stems from another evaluated set so we create a
// new container for its log messages then fill that container with
// a recursive call to renderHelper().
$link = NULL;
if (isset($this->logs[$line]['path'])) {
$link = Link::fromTextAndUrl($this->t('edit'), Url::fromUserInput('/' . $this->logs[$line]['path']))
->toString();
}
$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'])) . ' [' . $link . ']',
];
$thisline = $line;
$build[$thisline][] = $this->renderHelper($line);
}
else {
// This next entry is a leaf of the evaluated set so we just have to
// add the details of the log entry.
$link = NULL;
if (isset($this->logs[$line]['path']) && !isset($this->logs[$line]['scope'])) {
$link = [
'title' => $this->t('edit'),
'url' => Url::fromUserInput('/' . $this->logs[$line]['path']),
];
}
$build[$line] = [
'#theme' => 'rules_debug_log_element',
'#starttime' => $startTime,
'#timestamp' => $this->logs[$line]['timestamp'],
'#level' => $this->logs[$line]['level'],
// @codingStandardsIgnoreStart
// Need to filter out context keys that aren't recognized as
// placeholders for t(), because Drupal core no longer supports these.
'#text' => $this->t($this->logs[$line]['message'], $this->filterContext($this->logs[$line]['context'])),
// @codingStandardsIgnoreEnd
'#link' => $link,
];
if (isset($this->logs[$line]['scope']) && !$this->logs[$line]['scope']) {
// This was the last log entry of this set.
return [
'#theme' => 'item_list',
'#items' => $build,
];
}
}
$line++;
}
return [
'#theme' => 'item_list',
'#items' => $build,
];
}