MIDDAG for Moodle

coursegroup_item extends item

Domain model for Course Group items.

This class maps entity-specific fields (expiration, contextids) to underlying metadata stored in middag_itemmeta.

Table of Contents

Constants

FILEMANAGER_OPTIONS  = ['maxbytes' => 1024, 'subdirs' => 0, 'maxfiles' => 1, 'accepted_types' => ['web_image']]
File upload options for image_filemanager
TYPE  = 'course_group'
Logical TYPE this entity represents
METADATA_FIELDS  = [self::META_EXPIRATION, self::META_CONTEXTIDS]
Metadata keys supported by this entity
META_CONTEXTIDS  = 'contextids'
META_EXPIRATION  = 'expiration'
Metadata keys specific to this Domain

Properties

$metadata  : array<string, mixed>
$__relations  : array<string, mixed>

Methods

__call()  : mixed
Magic call handler for metadata getters and withers.
__construct()  : mixed
Item constructor (immutable).
__get()  : mixed
Property-style access: $item->parent.
__isset()  : bool
Check presence of a relation.
__set()  : void
Magic setter.
get_all_meta()  : array<string, mixed>
Get all metadata.
get_all_relations()  : array<string, mixed>
Get all currently loaded relations.
get_context_ids()  : array<string|int, int>
Returns an array of context IDs (all integers).
get_contextid()  : int|null
Get the Moodle context ID.
get_courseid()  : int|null
Get the related course ID.
get_description()  : string|null
Get the description text.
get_descriptionformat()  : int
Get the Moodle format constant for the description.
get_edit_url()  : moodle_url
Shortcut for the edit URL.
get_expiration()  : null|int
Get expiration timestamp (int).
get_fullname()  : string|null
Get the full display name.
get_guid()  : string|null
Get the GUID reference if present.
get_id()  : null|int
Get the item database identifier.
get_idnumber()  : string|null
Get the external idnumber.
get_meta()  : mixed
Retrieve a metadata value by key.
get_parent()  : int|null
Get the parent item ID when hierarchical.
get_relation()  : mixed
Public accessor for relations using snake_case.
get_shortname()  : string|null
Get the abbreviated name.
get_sortorder()  : int
Get the ordering value.
get_status()  : string
Get the current status identifier.
get_timecreated()  : int
Get creation timestamp.
get_timemodified()  : int
Get last modification timestamp.
get_type()  : string
Get the logical type identifier.
get_url()  : moodle_url
Get the URL for a specific action on this entity.
get_userid()  : int|null
Get the author/owner user ID.
get_usermodified()  : int|null
Get the user ID of the last modifier.
get_version()  : string|null
Get the semantic version string if tracked.
get_view_url()  : moodle_url
Shortcut for the view URL.
get_visible()  : int
Get the raw visibility flag.
get_webhook_url()  : moodle_url
Generate a webhook URL specific to this entity.
has_meta()  : bool
Check if a metadata key exists.
has_relation()  : bool
Returns TRUE if the relation was defined (even if value is null).
is_active()  : bool
Check if the item is active.
is_approved()  : bool
Check if the item is approved.
is_archived()  : bool
Determine if the item is archived.
is_canceled()  : bool
Check if the item is canceled.
is_completed()  : bool
Check if the item is completed.
is_deleted()  : bool
Determine if the item is marked as deleted.
is_disabled()  : bool
Check if the item is disabled.
is_draft()  : bool
Determine if the item is in draft state.
is_enabled()  : bool
Check if the item is enabled.
is_error()  : bool
Check if the item is in an error state.
is_expired()  : bool
Check if the item is expired.
is_failed()  : bool
Check if the item has failed.
is_in_progress()  : bool
Check if the item is in progress.
is_inactive()  : bool
Check if the item is inactive.
is_not_started()  : bool
Check if the item has not started.
is_paused()  : bool
Check if the item is paused.
is_pending()  : bool
Check if the item awaits processing.
is_published()  : bool
Determine if the item is published.
is_queued()  : bool
Check if the item is queued.
is_rejected()  : bool
Check if the item was rejected.
is_running()  : bool
Check if the item is running.
is_status()  : bool
Check if the current status matches a specific value or Enum case.
is_synced()  : bool
Check if the item finished syncing.
is_syncing()  : bool
Check if the item is syncing.
is_visible()  : bool
Domain logic: Is this item visible? Wraps the raw integer logic into a boolean.
jsonSerialize()  : array<string, mixed>
Serializes the object to a value that can be natively serialized by json_encode().
metadata_schema()  : array<string, string>
Define the metadata schema for this item type.
to_array()  : array<string, mixed>
Convert entity to array.
with_all_meta()  : static
Return a new instance replacing all metadata.
with_context_ids()  : self
Returns a clone with updated context IDs.
with_contextid()  : self
Create a new instance with the provided context ID.
with_courseid()  : self
Create a new instance with the provided course ID.
with_description()  : self
Create a new instance with the provided description.
with_descriptionformat()  : self
Create a new instance with the provided description format.
with_expiration()  : self
Returns a clone with expiration updated.
with_fullname()  : self
Create a new instance with the provided full name.
with_idnumber()  : self
Create a new instance with the provided idnumber.
with_meta()  : static
Return a new instance with the updated metadata (Immutable).
with_parent()  : self
Create a new instance with the provided parent ID.
with_shortname()  : self
Create a new instance with the provided short name.
with_sortorder()  : self
Create a new instance with the provided sort order.
with_status()  : self
Create a new instance with the provided status.
with_timemodified()  : self
Create a new instance with the provided modification time.
with_userid()  : self
Create a new instance with the provided user ID.
with_usermodified()  : self
Create a new instance with the provided last modifier.
with_version()  : self
Create a new instance with the provided version.
with_visible()  : self
Create a new instance with the provided visibility flag.

Constants

FILEMANAGER_OPTIONS

File upload options for image_filemanager

public mixed FILEMANAGER_OPTIONS = ['maxbytes' => 1024, 'subdirs' => 0, 'maxfiles' => 1, 'accepted_types' => ['web_image']]

TYPE

Logical TYPE this entity represents

public mixed TYPE = 'course_group'

METADATA_FIELDS

Metadata keys supported by this entity

protected mixed METADATA_FIELDS = [self::META_EXPIRATION, self::META_CONTEXTIDS]

META_EXPIRATION

Metadata keys specific to this Domain

private mixed META_EXPIRATION = 'expiration'

Properties

$metadata

protected array<string, mixed> $metadata = []

key/value

$__relations

private array<string, mixed> $__relations = []

Internal storage for loaded relations

Methods

__call()

Magic call handler for metadata getters and withers.

public __call(string $method, array<int, mixed> $arguments) : mixed

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

Parameters
$method : string
$arguments : array<int, mixed>

__construct()

Item constructor (immutable).

public __construct([null|int $id = null ][, string $type = self::TYPE ][, null|int $contextid = null ][, null|int $courseid = null ][, null|int $userid = null ][, null|int $parent = null ][, null|string $fullname = null ][, null|string $shortname = null ][, null|string $idnumber = null ][, null|string $description = null ][, int $descriptionformat = 0 ][, string $status = 'draft' ][, int $visible = 1 ][, null|string $guid = null ][, int $sortorder = 0 ][, null|string $version = null ][, int $timecreated = 0 ][, int $timemodified = 0 ][, null|int $usermodified = null ][, array<string, mixed> $metadata = [] ]) : mixed
Parameters
$id : null|int = null
$type : string = self::TYPE
$contextid : null|int = null
$courseid : null|int = null
$userid : null|int = null
$parent : null|int = null
$fullname : null|string = null
$shortname : null|string = null
$idnumber : null|string = null
$description : null|string = null
$descriptionformat : int = 0
$status : string = 'draft'
$visible : int = 1
$guid : null|string = null
$sortorder : int = 0
$version : null|string = null
$timecreated : int = 0
$timemodified : int = 0
$usermodified : null|int = null
$metadata : array<string, mixed> = []

Initial metadata

__get()

Property-style access: $item->parent.

public __get(string $name) : mixed

Convenience wrapper for get_relation().

Parameters
$name : string

__isset()

Check presence of a relation.

public __isset(string $name) : bool
Parameters
$name : string
Return values
bool

__set()

Magic setter.

public __set(string $name, mixed $value) : void
Parameters
$name : string

Property name

$value : mixed

Value

get_all_meta()

Get all metadata.

public get_all_meta() : array<string, mixed>
Return values
array<string, mixed>

get_all_relations()

Get all currently loaded relations.

public get_all_relations() : array<string, mixed>
Return values
array<string, mixed>

get_context_ids()

Returns an array of context IDs (all integers).

public get_context_ids() : array<string|int, int>

Get context IDs as an array.

Always returns an array; empty array if none defined.

Return values
array<string|int, int>

get_contextid()

Get the Moodle context ID.

public get_contextid() : int|null
Return values
int|null

get_courseid()

Get the related course ID.

public get_courseid() : int|null
Return values
int|null

get_description()

Get the description text.

public get_description() : string|null
Return values
string|null

get_descriptionformat()

Get the Moodle format constant for the description.

public get_descriptionformat() : int
Return values
int

get_edit_url()

Shortcut for the edit URL.

public get_edit_url() : moodle_url
Return values
moodle_url

get_expiration()

Get expiration timestamp (int).

public get_expiration() : null|int
Return values
null|int

Returns expiration timestamp (int|null)

get_fullname()

Get the full display name.

public get_fullname() : string|null
Return values
string|null

get_guid()

Get the GUID reference if present.

public get_guid() : string|null
Return values
string|null

get_id()

Get the item database identifier.

public get_id() : null|int
Return values
null|int

get_idnumber()

Get the external idnumber.

public get_idnumber() : string|null
Return values
string|null

get_meta()

Retrieve a metadata value by key.

public get_meta(string $key[, mixed $default = null ]) : mixed
Parameters
$key : string
$default : mixed = null

get_parent()

Get the parent item ID when hierarchical.

public get_parent() : int|null
Return values
int|null

get_relation()

Public accessor for relations using snake_case.

public get_relation(string $name) : mixed
Parameters
$name : string

get_shortname()

Get the abbreviated name.

public get_shortname() : string|null
Return values
string|null

get_sortorder()

Get the ordering value.

public get_sortorder() : int
Return values
int

get_status()

Get the current status identifier.

public get_status() : string
Return values
string

get_timecreated()

Get creation timestamp.

public get_timecreated() : int
Return values
int

get_timemodified()

Get last modification timestamp.

public get_timemodified() : int
Return values
int

get_type()

Get the logical type identifier.

public get_type() : string
Return values
string

get_url()

Get the URL for a specific action on this entity.

public get_url([string $action = 'view' ][, array<string, mixed> $params = [] ]) : moodle_url

Convention: Route name is "middag.{type}.{action}" Example: $item->get_url('edit') -> route('middag.generic.edit', ['id' => 123])

Parameters
$action : string = 'view'

the action suffix (view, edit, delete) or full route name

$params : array<string, mixed> = []

additional parameters

Return values
moodle_url

get_userid()

Get the author/owner user ID.

public get_userid() : int|null
Return values
int|null

get_usermodified()

Get the user ID of the last modifier.

public get_usermodified() : int|null
Return values
int|null

get_version()

Get the semantic version string if tracked.

public get_version() : string|null
Return values
string|null

get_view_url()

Shortcut for the view URL.

public get_view_url() : moodle_url
Return values
moodle_url

get_visible()

Get the raw visibility flag.

public get_visible() : int
Return values
int

get_webhook_url()

Generate a webhook URL specific to this entity.

public get_webhook_url(string $action[, array<string, mixed> $params = [] ]) : moodle_url
Parameters
$action : string
$params : array<string, mixed> = []
Return values
moodle_url

has_meta()

Check if a metadata key exists.

public has_meta(string $key) : bool
Parameters
$key : string
Return values
bool

has_relation()

Returns TRUE if the relation was defined (even if value is null).

public has_relation(string $name) : bool
Parameters
$name : string
Return values
bool

is_active()

Check if the item is active.

public is_active() : bool
Return values
bool

is_approved()

Check if the item is approved.

public is_approved() : bool
Return values
bool

is_archived()

Determine if the item is archived.

public is_archived() : bool
Return values
bool

is_canceled()

Check if the item is canceled.

public is_canceled() : bool
Return values
bool

is_completed()

Check if the item is completed.

public is_completed() : bool
Return values
bool

is_deleted()

Determine if the item is marked as deleted.

public is_deleted() : bool
Return values
bool

is_disabled()

Check if the item is disabled.

public is_disabled() : bool
Return values
bool

is_draft()

Determine if the item is in draft state.

public is_draft() : bool
Return values
bool

is_enabled()

Check if the item is enabled.

public is_enabled() : bool
Return values
bool

is_error()

Check if the item is in an error state.

public is_error() : bool
Return values
bool

is_expired()

Check if the item is expired.

public is_expired() : bool
Return values
bool

is_failed()

Check if the item has failed.

public is_failed() : bool
Return values
bool

is_in_progress()

Check if the item is in progress.

public is_in_progress() : bool
Return values
bool

is_inactive()

Check if the item is inactive.

public is_inactive() : bool
Return values
bool

is_not_started()

Check if the item has not started.

public is_not_started() : bool
Return values
bool

is_paused()

Check if the item is paused.

public is_paused() : bool
Return values
bool

is_pending()

Check if the item awaits processing.

public is_pending() : bool
Return values
bool

is_published()

Determine if the item is published.

public is_published() : bool
Return values
bool

is_queued()

Check if the item is queued.

public is_queued() : bool
Return values
bool

is_rejected()

Check if the item was rejected.

public is_rejected() : bool
Return values
bool

is_running()

Check if the item is running.

public is_running() : bool
Return values
bool

is_status()

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

public is_status(item_status|string $value) : bool
Parameters
$value : item_status|string
Return values
bool

is_synced()

Check if the item finished syncing.

public is_synced() : bool
Return values
bool

is_syncing()

Check if the item is syncing.

public is_syncing() : bool
Return values
bool

is_visible()

Domain logic: Is this item visible? Wraps the raw integer logic into a boolean.

public is_visible() : bool
Return values
bool

jsonSerialize()

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

public jsonSerialize() : array<string, mixed>
Tags
noinspection

PhpMethodNamingConventionInspection

Return values
array<string, mixed>

metadata_schema()

Define the metadata schema for this item type.

public static metadata_schema() : array<string, string>

Override this in subclasses to define typed metadata fields or validation rules.

Return values
array<string, string>

Map of key => Type/Rule

to_array()

Convert entity to array.

public to_array() : array<string, mixed>

Useful for DTO conversion or serialization.

Return values
array<string, mixed>

with_all_meta()

Return a new instance replacing all metadata.

public with_all_meta(array<string, mixed> $metadata) : static
Parameters
$metadata : array<string, mixed>
Return values
static

with_context_ids()

Returns a clone with updated context IDs.

public with_context_ids(array<string|int, int> $contextids) : self
Parameters
$contextids : array<string|int, int>
Return values
self

with_contextid()

Create a new instance with the provided context ID.

public with_contextid(null|int $contextid) : self
Parameters
$contextid : null|int

Context identifier

Return values
self

with_courseid()

Create a new instance with the provided course ID.

public with_courseid(null|int $courseid) : self
Parameters
$courseid : null|int

Course identifier

Return values
self

with_description()

Create a new instance with the provided description.

public with_description(null|string $description) : self
Parameters
$description : null|string

Description text

Return values
self

with_descriptionformat()

Create a new instance with the provided description format.

public with_descriptionformat(int $descriptionformat) : self
Parameters
$descriptionformat : int

Moodle format constant

Return values
self

with_expiration()

Returns a clone with expiration updated.

public with_expiration(int|null $value) : self
Parameters
$value : int|null
Return values
self

with_fullname()

Create a new instance with the provided full name.

public with_fullname(string $fullname) : self
Parameters
$fullname : string

Full display name

Return values
self

with_idnumber()

Create a new instance with the provided idnumber.

public with_idnumber(null|string $idnumber) : self
Parameters
$idnumber : null|string

External identifier

Return values
self

with_meta()

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

public with_meta(string $key, mixed $value) : static
Parameters
$key : string
$value : mixed
Return values
static

with_parent()

Create a new instance with the provided parent ID.

public with_parent(null|int $parent) : self
Parameters
$parent : null|int

Parent item identifier

Return values
self

with_shortname()

Create a new instance with the provided short name.

public with_shortname(null|string $shortname) : self
Parameters
$shortname : null|string

Short display name

Return values
self

with_sortorder()

Create a new instance with the provided sort order.

public with_sortorder(int $sortorder) : self
Parameters
$sortorder : int

Ordering value

Return values
self

with_status()

Create a new instance with the provided status.

public with_status(string $status) : self
Parameters
$status : string

Status identifier

Return values
self

with_timemodified()

Create a new instance with the provided modification time.

public with_timemodified(int $time) : self
Parameters
$time : int

Unix timestamp

Return values
self

with_userid()

Create a new instance with the provided user ID.

public with_userid(null|int $userid) : self
Parameters
$userid : null|int

User identifier

Return values
self

with_usermodified()

Create a new instance with the provided last modifier.

public with_usermodified(int $userid) : self
Parameters
$userid : int

User identifier

Return values
self

with_version()

Create a new instance with the provided version.

public with_version(null|string $version) : self
Parameters
$version : null|string

Semantic version string

Return values
self

with_visible()

Create a new instance with the provided visibility flag.

public with_visible(int $visible) : self
Parameters
$visible : int

Visibility flag (0/1)

Return values
self

        
On this page

Search results