MIDDAG for Moodle

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

Tags
see
user_support

For direct user lookups and profile field operations

Table of Contents

Methods

create_user()  : int
Create a new Moodle user with sensible defaults.
delete_user()  : bool
Delete (soft-delete) a user with existence check.
update_user()  : bool
Update an existing Moodle user with validation.

Methods

create_user()

Create a new Moodle user with sensible defaults.

public create_user(stdClass $userobj[, bool $updatepassword = false ][, bool $nologin = false ]) : int

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

Parameters
$userobj : stdClass

Object containing user properties (username, email, etc)

$updatepassword : bool = false

Force password change on first login

$nologin : bool = false

If true, user cannot login

Tags
throws
moodle_exception
Return values
int

New User ID

delete_user()

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

public delete_user(int $userid) : bool

Verifies the user exists before attempting deletion.

Parameters
$userid : int
Tags
throws
coding_exception
Return values
bool

True on success, false if user not found

update_user()

Update an existing Moodle user with validation.

public update_user(stdClass $userobj[, bool $updatepassword = true ][, bool $triggerevent = true ]) : bool

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

Parameters
$userobj : stdClass

Object with at least 'id' property

$updatepassword : bool = true

Hash password if changed

$triggerevent : bool = true

Fire \core\event\user_updated

Tags
throws
moodle_exception

If user ID is missing

Return values
bool

True on success


        
On this page

Search results