These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Drupal\mongodb_watchdog; |
||
| 4 | |||
| 5 | use Drupal\Core\Logger\RfcLogLevel; |
||
| 6 | use MongoDB\BSON\Unserializable; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Class Event. |
||
| 10 | * |
||
| 11 | * @package Drupal\mongodb_watchdog |
||
| 12 | */ |
||
| 13 | class Event implements Unserializable { |
||
| 14 | const KEYS = [ |
||
| 15 | '_id', |
||
| 16 | 'hostname', |
||
| 17 | 'link', |
||
| 18 | 'location', |
||
| 19 | 'message', |
||
| 20 | 'referrer', |
||
| 21 | 'severity', |
||
| 22 | 'timestamp', |
||
| 23 | 'type', |
||
| 24 | 'uid', |
||
| 25 | 'variables', |
||
| 26 | 'requestTracking_id', |
||
| 27 | 'requestTracking_sequence', |
||
| 28 | ]; |
||
| 29 | |||
| 30 | // @codingStandardsIgnoreStart |
||
| 31 | /** |
||
| 32 | * The string representation of a MongoId. |
||
| 33 | * |
||
| 34 | * @var int |
||
| 35 | */ |
||
| 36 | public $_id; |
||
| 37 | // @codingStandardsIgnoreEnd |
||
| 38 | |||
| 39 | /** |
||
| 40 | * User id. |
||
| 41 | * |
||
| 42 | * @var int |
||
| 43 | */ |
||
| 44 | public $uid; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Event type, often a module name. |
||
| 48 | * |
||
| 49 | * @var string |
||
| 50 | */ |
||
| 51 | public $type; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Event template. |
||
| 55 | * |
||
| 56 | * @var string |
||
| 57 | */ |
||
| 58 | public $message; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * The identifier of the request during which this event occurred. |
||
| 62 | * |
||
| 63 | * @var string |
||
| 64 | */ |
||
| 65 | public $requestTracking_id; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * The sequence number of the event during the request when it happened. |
||
| 69 | * |
||
| 70 | * @var int |
||
| 71 | */ |
||
| 72 | public $requestTracking_sequence = 0; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 73 | |||
| 74 | /** |
||
| 75 | * The template parameters. |
||
| 76 | * |
||
| 77 | * @var array |
||
| 78 | */ |
||
| 79 | public $variables; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * A RFC5424 severity level. |
||
| 83 | * |
||
| 84 | * @var int |
||
| 85 | */ |
||
| 86 | public $severity = RfcLogLevel::DEBUG; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * A link provided by the event emitter. Optional. |
||
| 90 | * |
||
| 91 | * @var string |
||
| 92 | */ |
||
| 93 | public $link; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * The absolute URL for the path on which the event was logged. |
||
| 97 | * |
||
| 98 | * @var string |
||
| 99 | */ |
||
| 100 | public $location; |
||
| 101 | |||
| 102 | /** |
||
| 103 | * A HTTP referrer for the path on which the event was logged. Optional. |
||
| 104 | * |
||
| 105 | * @var string |
||
| 106 | */ |
||
| 107 | public $referrer; |
||
| 108 | |||
| 109 | /** |
||
| 110 | * The server host. |
||
| 111 | * |
||
| 112 | * @var string |
||
| 113 | */ |
||
| 114 | public $hostname; |
||
| 115 | |||
| 116 | /** |
||
| 117 | * The timestamp at which the event was logged. |
||
| 118 | * |
||
| 119 | * @var int |
||
| 120 | */ |
||
| 121 | public $timestamp = 0; |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Constructor. |
||
| 125 | * |
||
| 126 | * @param array $event |
||
| 127 | * The event in array form. |
||
| 128 | */ |
||
| 129 | public function __construct(array $event) { |
||
| 130 | $this->bsonUnserialize($event); |
||
| 131 | } |
||
| 132 | |||
| 133 | /** |
||
| 134 | * {@inheritdoc} |
||
| 135 | */ |
||
| 136 | public function bsonUnserialize(array $data) { |
||
| 137 | foreach (static::KEYS as $key) { |
||
| 138 | if (isset($data[$key])) { |
||
| 139 | $this->{$key} = $data[$key]; |
||
| 140 | } |
||
| 141 | } |
||
| 142 | } |
||
| 143 | |||
| 144 | } |
||
| 145 |