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

array
jsonSerialize()

Default implementation to serialize to JSON using the array representation.

__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.

from  item_dto
static item_dto
from_array(array $data)

Create a DTO from an associative array (e.g. form data or JSON).

from  item_dto
array
to_array()

Convert DTO to an array, filtering out null values.

from  item_dto

Details

in abstract_dto at line 38
array jsonSerialize()

Default implementation to serialize to JSON using the array representation.

Return Value

array

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).

Parameters

int|null $id

Item ID (null for creation)

string|null $type

Logical TYPE identifier

int|null $contextid

Moodle context ID

int|null $courseid

Course ID

int|null $userid

Entity owner (creator)

int|null $parent

Parent item ID

string|null $fullname

Full name/title

string|null $shortname

Short/abbreviated label

string|null $idnumber

External reference

string|null $description

Long description (HTML/text)

int|null $descriptionformat

Moodle text format

string|null $status

Logical workflow/status

int|null $visible

Visibility flag (0/1)

string|null $guid

External unique identifier

int|null $sortorder

Ordering index

string|null $version

Arbitrary version tag

int|null $usermodified

User performing the operation

array $metadata

Arbitrary key/value metadata

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.

Parameters

array $data

Return Value

item_dto

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.

Return Value

array