item_dto
abstract class item_dto extends item_dto
Public SDK DTO (Data Transfer Object).
Extend this class to declare immutable, typed data structures exchanged between your services, widgets, and controllers.
Methods
Default implementation to serialize to JSON using the array representation.
DTO constructor.
Create a DTO from an associative array (e.g. form data or JSON).
Details
in
abstract_dto at line 38
array
jsonSerialize()
Default implementation to serialize to JSON using the array representation.
in
item_dto at line 62
__construct(int|null $id = null, string|null $type = item::TYPE, int|null $contextid = null, int|null $courseid = null, int|null $userid = null, int|null $parent = null, string|null $fullname = null, string|null $shortname = null, string|null $idnumber = null, string|null $description = null, int|null $descriptionformat = 0, string|null $status = 'draft', int|null $visible = 1, string|null $guid = null, int|null $sortorder = 0, string|null $version = null, int|null $usermodified = null, array $metadata = [])
DTO constructor.
All fields are nullable to support partial updates (PATCH-like behavior).
in
item_dto at line 94
static item_dto
from_array(array $data)
Create a DTO from an associative array (e.g. form data or JSON).
Keys not present in the array will remain null (not updated). Unknown keys are ignored.
in
item_dto at line 125
array
to_array()
Convert DTO to an array, filtering out null values.
Useful for repository methods that should receive only changed fields.