-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathLoggerEntry.php
More file actions
78 lines (65 loc) · 1.95 KB
/
LoggerEntry.php
File metadata and controls
78 lines (65 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* @file
* Contains \Drupal\rules\Plugin\DataType\LoggerEntry.
*/
namespace Drupal\rules\Plugin\DataType;
use Drupal\Core\TypedData\Plugin\DataType\Map;
/**
* The logger entry data type.
*
* @see: https://www.drupal.org/node/2625238
*
* @ingroup typed_data
*
* @DataType(
* id = "loggerentry",
* label = @Translation("Logger Entry"),
* definition_class = "\Drupal\Core\TypedData\MapDataDefinition"
* )
*/
class LoggerEntry extends Map {
/**
* The data definition.
*
* @var \Drupal\Core\TypedData\ComplexDataDefinitionInterface
*/
protected $definition;
/**
* An array of values for the contained properties.
*
* @var array
*/
protected $values = array();
/**
* The array of properties.
*
* @var \Drupal\Core\TypedData\TypedDataInterface[]
*/
protected $properties = array();
public function __construct(DataDefinitionInterface $definition, $name, TypedDataInterface $parent, $logger_entry_context) {
parent::__construct($definition, $name, $parent);
$this->values = $this->createLoggerEntryFromContext($logger_entry_context)
}
// Plain copy from \Drupal\rules\Logger\RulesLog
protected function createLoggerEntryFromContext($context) {
// Remove any backtraces since they may contain an unserializable variable.
unset($context['backtrace']);
// Convert PSR3-style messages to SafeMarkup::format() style, so they can be
// translated too in runtime.
$message_placeholders = $this->parser->parseMessagePlaceholders($message, $context);
$logger_entry = array(
'uid' => $context['uid'],
'type' => $context['channel'],
'message' => $message,
'variables' => $message_placeholders,
'severity' => $level,
'link' => $context['link'],
'location' => $context['request_uri'],
'referer' => $context['referer'],
'hostname' => $context['ip'],
'timestamp' => $context['timestamp'],
);
return $logger_entry;
}
}