MIDDAG for Moodle

event extends abstract_entity implements event_interface

Domain Entity: Event (Audit Log).

Represents a persistent audit record in 'middag_event'. It aggregates the related Diffs and Snapshot via Value Objects.

Table of Contents

Interfaces

event_interface
Interface Event (Audit Log).

Properties

$context_data_array  : array<string, mixed>
$diffs  : array<string|int, revision_diff>
$eventtype  : string
$extension  : string
$hasdiff  : int
$hassnapshot  : int
$id  : int|null
$itemid  : int|null
$message  : string|null
$origin  : string
$snapshot  : null|snapshot_data
$timecreated  : int
$userid  : int|null

Methods

__construct()  : mixed
Instantiate an Event aggregate.
__get()  : mixed
Magic getter to allow reading protected properties.
__isset()  : bool
Magic isset to allow checking protected properties.
__set()  : void
Magic setter.
create()  : self
Factory method to start a new event recording.
get_contextdata()  : array<string, mixed>
Get decoded context payload.
get_diffs()  : array<string|int, revision_diff>
Get the list of field changes attached to this event.
get_eventtype()  : string
Get the event type identifier.
get_extension()  : string
Get the emitting extension slug.
get_id()  : null|int
Get the event database identifier.
get_itemid()  : null|int
Get the related item identifier.
get_message()  : string|null
Get the human-readable message if any.
get_origin()  : string
Get the origin source (web, api, cli, system).
get_snapshot()  : null|snapshot_data
Get the full snapshot if it was recorded.
get_timecreated()  : int
Get creation timestamp.
get_userid()  : int|null
Get the user ID responsible for the action.
has_diff()  : bool
Check whether diffs were recorded.
has_snapshot()  : bool
Check whether a snapshot was recorded.
jsonSerialize()  : array<string, mixed>
Serializes the object to a value that can be natively serialized by json_encode().
to_array()  : array<string, mixed>
Export the event as an associative array for serialization.
with_diff()  : self
Returns a new Event instance with the added Diff.
with_message()  : self
Clone the event updating its message.
with_snapshot()  : self
Returns a new Event instance with the snapshot set.

Properties

$context_data_array

private array<string, mixed> $context_data_array = []

Decoded context data

$diffs

private array<string|int, revision_diff> $diffs = []

List of field changes associated with this event

$eventtype

private string $eventtype

$extension

private string $extension

$hasdiff

private int $hasdiff = 0

$hassnapshot

private int $hassnapshot = 0

$itemid

private int|null $itemid

$message

private string|null $message = null

$origin

private string $origin = 'system'

$snapshot

private null|snapshot_data $snapshot = null

Full snapshot of the item at the time of event

$timecreated

private int $timecreated = 0

$userid

private int|null $userid

Methods

__construct()

Instantiate an Event aggregate.

public __construct(null|int $id, null|int $itemid, string $extension, string $eventtype, null|int $userid[, string $origin = 'system' ][, null|string $message = null ][, null|array<string, mixed>|string $contextdata = null ][, int $hasdiff = 0 ][, int $hassnapshot = 0 ][, int $timecreated = 0 ]) : mixed
Parameters
$id : null|int
$itemid : null|int
$extension : string
$eventtype : string
$userid : null|int
$origin : string = 'system'
$message : null|string = null
$contextdata : null|array<string, mixed>|string = null

Raw JSON or decoded array

$hasdiff : int = 0
$hassnapshot : int = 0
$timecreated : int = 0

__get()

Magic getter to allow reading protected properties.

public __get(string $name) : mixed
Parameters
$name : string

Property name

__isset()

Magic isset to allow checking protected properties.

public __isset(string $name) : bool
Parameters
$name : string

Property name

Return values
bool

__set()

Magic setter.

public __set(string $name, mixed $value) : void
Parameters
$name : string

Property name

$value : mixed

Value

create()

Factory method to start a new event recording.

public static create(string $extension, string $eventtype[, null|int $itemid = null ][, null|int $userid = null ][, null|int $timecreated = null ]) : self
Parameters
$extension : string

Extension slug

$eventtype : string

Event type identifier

$itemid : null|int = null

Related item ID

$userid : null|int = null

Actor ID

$timecreated : null|int = null

Optional creation timestamp

Return values
self

get_contextdata()

Get decoded context payload.

public get_contextdata() : array<string, mixed>
Return values
array<string, mixed>

get_diffs()

Get the list of field changes attached to this event.

public get_diffs() : array<string|int, revision_diff>
Return values
array<string|int, revision_diff>

get_eventtype()

Get the event type identifier.

public get_eventtype() : string
Return values
string

get_extension()

Get the emitting extension slug.

public get_extension() : string
Return values
string

get_id()

Get the event database identifier.

public get_id() : null|int
Return values
null|int

get_itemid()

Get the related item identifier.

public get_itemid() : null|int
Return values
null|int

get_message()

Get the human-readable message if any.

public get_message() : string|null
Return values
string|null

get_origin()

Get the origin source (web, api, cli, system).

public get_origin() : string
Return values
string

get_timecreated()

Get creation timestamp.

public get_timecreated() : int
Return values
int

get_userid()

Get the user ID responsible for the action.

public get_userid() : int|null
Return values
int|null

has_diff()

Check whether diffs were recorded.

public has_diff() : bool
Return values
bool

has_snapshot()

Check whether a snapshot was recorded.

public has_snapshot() : bool
Return values
bool

jsonSerialize()

Serializes the object to a value that can be natively serialized by json_encode().

public jsonSerialize() : array<string, mixed>
Tags
noinspection

PhpMethodNamingConventionInspection

Return values
array<string, mixed>

to_array()

Export the event as an associative array for serialization.

public to_array() : array<string, mixed>
Return values
array<string, mixed>

with_diff()

Returns a new Event instance with the added Diff.

public with_diff(revision_diff $diff) : self
Parameters
$diff : revision_diff
Return values
self

with_message()

Clone the event updating its message.

public with_message(string $message) : self
Parameters
$message : string
Return values
self

with_snapshot()

Returns a new Event instance with the snapshot set.

public with_snapshot(snapshot_data $snapshot) : self
Parameters
$snapshot : snapshot_data
Return values
self

        
On this page

Search results