-
New Feature
-
Resolution: Deferred
-
Minor
-
None
-
3.4.2
-
None
-
MOODLE_34_STABLE
-
Privacy Sprint 1
In the get_contexts_for_userid() provider method, it would be useful to be able to add known contexts directly when a plugin stores all its data at that context. The only two use cases for this I can think of are the system context and the user context, so it may not be worth making set_contextids() public, but a couple of helper methods like add_system_context() and add_user_context($userid) would be useful.
At the moment you have to do something like this, which seems absurd:
public static function get_contexts_for_userid(int $userid): contextlist {
|
$result = new contextlist('local_someplugin');
|
$result->add_from_sql('SELECT id FROM {context} WHERE id = ?', [\context_system::instance()->id]);
|
return $result;
|
}
|
- is duplicated by
-
MDL-62140 Add helper functions to add system and user context to contextlist
-
- Closed
-