Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Protected Attributes | List of all members
core_availability\capability_checker Class Reference

Used while evaluating conditions in bulk. More...

Public Member Functions

 __construct (\context $context)
 Constructs for given context. More...
 
 get_users_by_capability ($capability)
 Gets users on course who have the specified capability. More...
 

Protected Attributes

array $cache = array()
 Associative array of capability => result.
 
context $context
 Course or module context.
 

Detailed Description

Used while evaluating conditions in bulk.

This object caches get_users_by_capability results in case they are needed by multiple conditions.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core_availability\capability_checker::__construct ( \context  $context)

Constructs for given context.

Parameters
context$contextContext

Member Function Documentation

◆ get_users_by_capability()

core_availability\capability_checker::get_users_by_capability (   $capability)

Gets users on course who have the specified capability.

Returns an array of user objects which only contain the 'id' field. If the same capability has already been checked (e.g. by another condition) then a cached result will be used.

More fields are not necessary because this code is only used to filter users from an existing list.

Parameters
string$capabilityRequired capability
Return values
arrayAssociative array of user id => objects containing only id

The documentation for this class was generated from the following file: