class revision extends revision

Public SDK Revision Entity.

Acts as a stable representation of revisions returned by framework services for consumption inside extensions.

Traits

Trait has_metadata.

Trait has_status.

Properties

array<string,mixed> $metadata

Expected property on the consuming class.

from  has_metadata
string $status

Expected property on the using class.

from  has_status

Methods

mixed
__get(string $name)

Magic getter to allow reading protected properties.

bool
__isset(string $name)

Magic isset to allow checking protected properties.

void
__set(string $name, mixed $value)

Magic setter.

array
jsonSerialize()

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

mixed
__call(string $method, array $arguments)

Magic call handler for metadata getters and withers.

mixed
get_meta(string $key, mixed $default = null)

Retrieve a metadata value by key.

bool
has_meta(string $key)

Check if a metadata key exists.

array
get_all_meta()

Get all metadata.

with_meta(string $key, mixed $value)

Return a new instance with the updated metadata (Immutable).

with_all_meta(array $metadata)

Return a new instance replacing all metadata.

bool
is_status(item_status|string $value)

Check if the current status matches a specific value or Enum case.

bool
is_draft()

Determine if the item is in draft state.

bool
is_published()

Determine if the item is published.

bool
is_archived()

Determine if the item is archived.

bool
is_deleted()

Determine if the item is marked as deleted.

bool
is_active()

Check if the item is active.

bool
is_inactive()

Check if the item is inactive.

bool
is_enabled()

Check if the item is enabled.

bool
is_disabled()

Check if the item is disabled.

bool
is_pending()

Check if the item awaits processing.

bool
is_approved()

Check if the item is approved.

bool
is_rejected()

Check if the item was rejected.

bool
is_not_started()

Check if the item has not started.

bool
is_in_progress()

Check if the item is in progress.

bool
is_completed()

Check if the item is completed.

bool
is_failed()

Check if the item has failed.

bool
is_expired()

Check if the item is expired.

bool
is_canceled()

Check if the item is canceled.

bool
is_paused()

Check if the item is paused.

bool
is_queued()

Check if the item is queued.

bool
is_running()

Check if the item is running.

bool
is_syncing()

Check if the item is syncing.

bool
is_synced()

Check if the item finished syncing.

bool
is_error()

Check if the item is in an error state.

__construct(int|null $id, int $itemid, int $revisionnumber, string $revisionformat, string $type, int|null $contextid, int|null $courseid, int|null $userid, int|null $parent, string|null $fullname, string|null $shortname, string|null $idnumber, string|null $description, int $descriptionformat, string $status, int $visible, string|null $guid, int $sortorder, string|null $version, int|null $usermodified, int|null $usercreated, int $timecreated, array $metadata = [])

Create an immutable revision snapshot.

from  revision
int|null
get_id()

Get the revision database identifier.

from  revision
int
get_itemid()

Get the original item ID.

from  revision
int
get_revisionnumber()

Get the sequential revision number.

from  revision
string
get_revisionformat()

Get the format identifier (json, structured, etc.).

from  revision
string
get_type()

Get the item type stored in this revision.

from  revision
int|null
get_contextid()

Get the context ID snapshot.

from  revision
int|null
get_courseid()

Get the course ID snapshot.

from  revision
int|null
get_userid()

Get the owner/author ID snapshot.

from  revision
int|null
get_parent()

Get the parent item snapshot.

from  revision
string|null
get_fullname()

Get the full name snapshot.

from  revision
string|null
get_shortname()

Get the short name snapshot.

from  revision
string|null
get_idnumber()

Get the idnumber snapshot.

from  revision
string|null
get_description()

Get the description snapshot.

from  revision
int
get_descriptionformat()

Get the description format snapshot.

from  revision
string
get_status()

Get the status recorded in this revision.

from  revision
int
get_visible()

Get the raw visibility flag.

from  revision
bool
is_visible()

Domain visibility check.

from  revision
string|null
get_guid()

Get the GUID snapshot.

from  revision
int
get_sortorder()

Get the sort order snapshot.

from  revision
string|null
get_version()

Get the version snapshot.

from  revision
int|null
get_usermodified()

Get the user who last modified the original item.

from  revision
int|null
get_usercreated()

Get the user who created the revision.

from  revision
int
get_timecreated()

Get the timestamp when the revision was created.

from  revision
array
to_array()

Converts the revision back to an array for potential restoration.

from  revision

Details

in abstract_entity at line 39
mixed __get(string $name)

Magic getter to allow reading protected properties.

Parameters

string $name

Property name

Return Value

mixed

in abstract_entity at line 55
bool __isset(string $name)

Magic isset to allow checking protected properties.

Parameters

string $name

Property name

Return Value

bool

in abstract_entity at line 66
void __set(string $name, mixed $value)

Magic setter.

Parameters

string $name

Property name

mixed $value Value

Return Value

void

in abstract_entity at line 80
array jsonSerialize()

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

Return Value

array

in has_metadata at line 46
mixed __call(string $method, array $arguments)

Magic call handler for metadata getters and withers.

Allows accessing metadata like $item->get_price() or $item->with_price(10).

Parameters

string $method
array $arguments

Return Value

mixed

in has_metadata at line 79
mixed get_meta(string $key, mixed $default = null)

Retrieve a metadata value by key.

Parameters

string $key
mixed $default

Return Value

mixed

in has_metadata at line 95
bool has_meta(string $key)

Check if a metadata key exists.

Parameters

string $key

Return Value

bool

in has_metadata at line 109
array get_all_meta()

Get all metadata.

Return Value

array

in has_metadata at line 124
has_metadata with_meta(string $key, mixed $value)

Return a new instance with the updated metadata (Immutable).

Parameters

string $key
mixed $value

Return Value

has_metadata

in has_metadata at line 144
has_metadata with_all_meta(array $metadata)

Return a new instance replacing all metadata.

Parameters

array $metadata

Return Value

has_metadata

in has_status at line 39
bool is_status(item_status|string $value)

Check if the current status matches a specific value or Enum case.

Parameters

item_status|string $value

Return Value

bool

in has_status at line 61
bool is_draft()

Determine if the item is in draft state.

Return Value

bool

in has_status at line 69
bool is_published()

Determine if the item is published.

Return Value

bool

in has_status at line 77
bool is_archived()

Determine if the item is archived.

Return Value

bool

in has_status at line 85
bool is_deleted()

Determine if the item is marked as deleted.

Return Value

bool

in has_status at line 97
bool is_active()

Check if the item is active.

Return Value

bool

in has_status at line 105
bool is_inactive()

Check if the item is inactive.

Return Value

bool

in has_status at line 113
bool is_enabled()

Check if the item is enabled.

Return Value

bool

in has_status at line 121
bool is_disabled()

Check if the item is disabled.

Return Value

bool

in has_status at line 133
bool is_pending()

Check if the item awaits processing.

Return Value

bool

in has_status at line 141
bool is_approved()

Check if the item is approved.

Return Value

bool

in has_status at line 149
bool is_rejected()

Check if the item was rejected.

Return Value

bool

in has_status at line 161
bool is_not_started()

Check if the item has not started.

Return Value

bool

in has_status at line 169
bool is_in_progress()

Check if the item is in progress.

Return Value

bool

in has_status at line 177
bool is_completed()

Check if the item is completed.

Return Value

bool

in has_status at line 185
bool is_failed()

Check if the item has failed.

Return Value

bool

in has_status at line 193
bool is_expired()

Check if the item is expired.

Return Value

bool

in has_status at line 201
bool is_canceled()

Check if the item is canceled.

Return Value

bool

in has_status at line 209
bool is_paused()

Check if the item is paused.

Return Value

bool

in has_status at line 221
bool is_queued()

Check if the item is queued.

Return Value

bool

in has_status at line 229
bool is_running()

Check if the item is running.

Return Value

bool

in has_status at line 237
bool is_syncing()

Check if the item is syncing.

Return Value

bool

in has_status at line 245
bool is_synced()

Check if the item finished syncing.

Return Value

bool

in has_status at line 257
bool is_error()

Check if the item is in an error state.

Return Value

bool

in revision at line 65
__construct(int|null $id, int $itemid, int $revisionnumber, string $revisionformat, string $type, int|null $contextid, int|null $courseid, int|null $userid, int|null $parent, string|null $fullname, string|null $shortname, string|null $idnumber, string|null $description, int $descriptionformat, string $status, int $visible, string|null $guid, int $sortorder, string|null $version, int|null $usermodified, int|null $usercreated, int $timecreated, array $metadata = [])

Create an immutable revision snapshot.

Parameters

int|null $id
int $itemid
int $revisionnumber
string $revisionformat
string $type
int|null $contextid
int|null $courseid
int|null $userid
int|null $parent
string|null $fullname
string|null $shortname
string|null $idnumber
string|null $description
int $descriptionformat
string $status
int $visible
string|null $guid
int $sortorder
string|null $version
int|null $usermodified
int|null $usercreated
int $timecreated
array $metadata

in revision at line 98
int|null get_id()

Get the revision database identifier.

Return Value

int|null

in revision at line 106
int get_itemid()

Get the original item ID.

Return Value

int

in revision at line 114
int get_revisionnumber()

Get the sequential revision number.

Return Value

int

in revision at line 122
string get_revisionformat()

Get the format identifier (json, structured, etc.).

Return Value

string

in revision at line 130
string get_type()

Get the item type stored in this revision.

Return Value

string

in revision at line 138
int|null get_contextid()

Get the context ID snapshot.

Return Value

int|null

in revision at line 146
int|null get_courseid()

Get the course ID snapshot.

Return Value

int|null

in revision at line 154
int|null get_userid()

Get the owner/author ID snapshot.

Return Value

int|null

in revision at line 162
int|null get_parent()

Get the parent item snapshot.

Return Value

int|null

in revision at line 170
string|null get_fullname()

Get the full name snapshot.

Return Value

string|null

in revision at line 178
string|null get_shortname()

Get the short name snapshot.

Return Value

string|null

in revision at line 186
string|null get_idnumber()

Get the idnumber snapshot.

Return Value

string|null

in revision at line 194
string|null get_description()

Get the description snapshot.

Return Value

string|null

in revision at line 202
int get_descriptionformat()

Get the description format snapshot.

Return Value

int

in revision at line 210
string get_status()

Get the status recorded in this revision.

Return Value

string

in revision at line 218
int get_visible()

Get the raw visibility flag.

Return Value

int

in revision at line 226
bool is_visible()

Domain visibility check.

Return Value

bool

in revision at line 234
string|null get_guid()

Get the GUID snapshot.

Return Value

string|null

in revision at line 242
int get_sortorder()

Get the sort order snapshot.

Return Value

int

in revision at line 250
string|null get_version()

Get the version snapshot.

Return Value

string|null

in revision at line 258
int|null get_usermodified()

Get the user who last modified the original item.

Return Value

int|null

in revision at line 266
int|null get_usercreated()

Get the user who created the revision.

Return Value

int|null

in revision at line 274
int get_timecreated()

Get the timestamp when the revision was created.

Return Value

int

in revision at line 284
array to_array()

Converts the revision back to an array for potential restoration.

Return Value

array