class context extends abstract_moodle_entity

Context Entity (Moodle Native).

Properties

protected int $id from  abstract_moodle_entity
protected int $timecreated from  abstract_moodle_entity
protected int $timemodified from  abstract_moodle_entity
protected int $contextlevel
protected int $instanceid
protected string|null $path
protected int $depth
protected int $locked

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 $name, array $arguments)

Magic accessor to support get* and with* helpers for entity properties.

static string
get_table()

Returns the Moodle database table name.

from_record(array|stdClass $record)

Factory method to create an entity from a Moodle record.

to_record()

Converts the entity to a stdClass record for Moodle APIs.

as_std_class()

Returns the entity as stdClass (alias for to_record).

int|null
get_id()

Get the entity unique identifier.

with_id(int|null $id)

Set entity identifier.

int
get_timecreated()

Get entity creation timestamp.

with_timecreated(int $timecreated)

Set entity creation timestamp.

int
get_timemodified()

Get entity modification timestamp.

with_timemodified(int $timemodified)

Set entity modification timestamp.

array
to_array()

Implementation for entity_interface.

static context
from_context(context $context)

Factory method from Moodle context object.

int
get_contextlevel()

No description

self
with_contextlevel(int $contextlevel)

No description

int
get_instanceid()

No description

self
with_instanceid(int $instanceid)

No description

null|string
get_path()

No description

self
with_path(?string $path)

No description

int
get_depth()

No description

self
with_depth(int $depth)

No description

int
get_locked()

No description

self
with_locked(int $locked)

No description

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

mixed __call(string $name, array $arguments)

Magic accessor to support get* and with* helpers for entity properties.

Parameters

string $name
array $arguments

Return Value

mixed

at line 52
static string get_table()

Returns the Moodle database table name.

Return Value

string

static abstract_moodle_entity from_record(array|stdClass $record)

Factory method to create an entity from a Moodle record.

Automatically casts values to match property types (int, string, etc.) since Moodle's database layer often returns numeric values as strings.

Parameters

array|stdClass $record

Return Value

abstract_moodle_entity

stdClass to_record()

Converts the entity to a stdClass record for Moodle APIs.

Return Value

stdClass

stdClass as_std_class()

Returns the entity as stdClass (alias for to_record).

Return Value

stdClass

int|null get_id()

Get the entity unique identifier.

Return Value

int|null

abstract_moodle_entity with_id(int|null $id)

Set entity identifier.

Parameters

int|null $id

Return Value

abstract_moodle_entity

int get_timecreated()

Get entity creation timestamp.

Return Value

int

abstract_moodle_entity with_timecreated(int $timecreated)

Set entity creation timestamp.

Parameters

int $timecreated

Return Value

abstract_moodle_entity

int get_timemodified()

Get entity modification timestamp.

Return Value

int

abstract_moodle_entity with_timemodified(int $timemodified)

Set entity modification timestamp.

Parameters

int $timemodified

Return Value

abstract_moodle_entity

array to_array()

Implementation for entity_interface.

Return Value

array

at line 64
static context from_context(context $context)

Factory method from Moodle context object.

Parameters

context $context

Return Value

context

at line 37
int get_contextlevel()

No description

Return Value

int

at line 37
self with_contextlevel(int $contextlevel)

No description

Parameters

int $contextlevel

Return Value

self

at line 37
int get_instanceid()

No description

Return Value

int

at line 37
self with_instanceid(int $instanceid)

No description

Parameters

int $instanceid

Return Value

self

at line 37
null|string get_path()

No description

Return Value

null|string

at line 37
self with_path(?string $path)

No description

Parameters

?string $path

Return Value

self

at line 37
int get_depth()

No description

Return Value

int

at line 37
self with_depth(int $depth)

No description

Parameters

int $depth

Return Value

self

at line 37
int get_locked()

No description

Return Value

int

at line 37
self with_locked(int $locked)

No description

Parameters

int $locked

Return Value

self