interface user_service_interface

Contract for User Management Service.

This service provides orchestration logic for user lifecycle operations. For simple user lookups (get_user, get_user_by_email, etc.), use the Support layer directly: \local_middag\framework\support\moodle\user

Methods

int
create_user(stdClass $userobj, bool $updatepassword = false, bool $nologin = false)

Create a new Moodle user with sensible defaults.

bool
update_user(stdClass $userobj, bool $updatepassword = true, bool $triggerevent = true)

Update an existing Moodle user with validation.

bool
delete_user(int $userid)

Delete (soft-delete) a user with existence check.

Details

at line 49
int create_user(stdClass $userobj, bool $updatepassword = false, bool $nologin = false)

Create a new Moodle user with sensible defaults.

This method applies default values for auth, confirmed, and mnethostid if not provided, then delegates to the Support layer.

Parameters

stdClass $userobj

Object containing user properties (username, email, etc)

bool $updatepassword

Force password change on first login

bool $nologin

If true, user cannot login

Return Value

int

New User ID

Exceptions

moodle_exception

at line 64
bool update_user(stdClass $userobj, bool $updatepassword = true, bool $triggerevent = true)

Update an existing Moodle user with validation.

Validates that the user ID is present before delegating to Support.

Parameters

stdClass $userobj

Object with at least 'id' property

bool $updatepassword

Hash password if changed

bool $triggerevent

Fire \core\event\user_updated

Return Value

bool

True on success

Exceptions

moodle_exception

at line 77
bool delete_user(int $userid)

Delete (soft-delete) a user with existence check.

Verifies the user exists before attempting deletion.

Parameters

int $userid

Return Value

bool

True on success, false if user not found

Exceptions

coding_exception