LMSouq
moodle-core Open

PHP - Exception Class not found - wrong namespace

MA
marcocassisa
1 month ago
3 views
Problem Description
After instantiating moodle "externally" through require_once('../config.php'); in a SSO scenario inside an application (namely [MRBS][1]), i get an error: `Exception - Class "MRBS\Session\context_block" not found` when it comes to find out if the currently logged user has some capability on a specific block: if (has_capability('moodle/block:edit', context_block::instance($blockid)){} I guess it is because the namespace is set to `namespace MRBS\Session;` How can I correctly refer to `context_block::instance()`? Moodle functions apparently work (e.g. require_login(), has_capability). Thanks [1]: https://github.com/meeting-room-booking-system/mrbs-code

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base