item_dto
class item_dto extends abstract_dto implements item_dto_interface
| internal |
Data Transfer Object (DTO) for items.
A unified input model for creating and updating items. It is intentionally mutable to support form hydration and stepwise population.
Rules:
- When creating: id = null
- When updating: id != null
- Any field set to null will not override existing entity values (Partial Update)
- Only metadata keys provided here will be merged/updated
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).
Convert DTO to an array, filtering out null values.
Details
in
abstract_dto at line 38
array
jsonSerialize()
Default implementation to serialize to JSON using the array representation.
at line 64
__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).
at line 96
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.
at line 127
array
to_array()
Convert DTO to an array, filtering out null values.
Useful for repository methods that should receive only changed fields.