Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

(no description)

File Size: 353 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: user_repository  - X-Ref

Class user_repository.

This class encapsulates persistence logic for \enrol_lti\local\entity\user type objects.

user_from_record(\stdClass $userrecord)   X-Ref
Convert a record into a user object and return it.

param: \stdClass $userrecord the raw data from relevant tables required to instantiate a user.
return: user a user object.

users_from_records(array $records)   X-Ref
Create a list of user instances from a list of records.

param: array $records the array of records.
return: array of user instances.

user_record_from_user(user $user)   X-Ref
Get a stdClass object ready for persisting, based on the supplied user object.

param: user $user the user instance.
return: \stdClass the record.

lti_user_record_from_user(user $user)   X-Ref
Create the corresponding enrol_lti_user record from a user instance.

param: user $user the user instance.
return: \stdClass the record.

user_exists_for_tool(user $user)   X-Ref
Helper to validate user:tool uniqueness across a deployment.

The DB cannot be relied on to do this uniqueness check, since the table is shared by LTI 1.1/2.0 data.

param: user $user the user instance.
return: bool true if found, false otherwise.

save(user $user)   X-Ref
Save a user instance in the store.

param: user $user the object to save.
return: user the saved object.

find(int $id)   X-Ref
Find and return a user by id.

param: int $id the id of the user object.
return: user|null the user object, or null if the object cannot be found.

find_single_user_by_resource(int $userid, int $resourceid)   X-Ref
Find an lti user instance by resource.

param: int $userid the id of the moodle user to look for.
param: int $resourceid the id of the published resource.
return: user|null the lti user instance, or null if not found.

find_by_resource(int $resourceid)   X-Ref
Find all users for a particular shared resource.

param: int $resourceid the id of the shared resource.
return: array the array of users, empty if none were found.

find_by_resource_link(int $resourcelinkid)   X-Ref
Get a list of users associated with the given resource link.

param: int $resourcelinkid the id of the resource_link instance with which the users are associated.
return: array the array of users, empty if none were found.

exists(int $id)   X-Ref
Check whether or not the given user object exists.

param: int $id the unique id the user.
return: bool true if found, false otherwise.

delete(int $id)   X-Ref
Delete a user based on id.

param: int $id the id of the user to remove.

delete_by_deployment(int $deploymentid)   X-Ref
Delete all lti user instances based on a given local deployment instance id.

param: int $deploymentid the local id of the deployment instance to which the users belong.