Moodle Boundary¶
Namespace: local_middag\framework\moodle.
All interaction with Moodle's native APIs is contained in framework/moodle/. No other layer of the framework calls Moodle functions, globals, or classes directly (ADR-201).
Three Families¶
| Family | Subdirectories | Purpose |
|---|---|---|
| Runtime wrappers | support/, adapter/, service/ |
Wrap executable Moodle APIs |
| Declarative bridges | definition/, settings/, form/ |
Typed DSL for Moodle declarative systems |
| Typed domain | entity/, dto/, enum/, contract/, value_object/ |
Typed vocabulary for the boundary |
Support Layer (ADR-203)¶
40 static wrapper classes in moodle/support/. Each wraps one Moodle subsystem:
| Group | Supports |
|---|---|
| Data/Persistence | db_support, cache_support, config_support, preference_support |
| Auth/Authorization | auth_support, capability_support, session_support, role_support |
| Context/Entities | context_support, user_support, course_support, category_support, group_support, cohort_support, enrol_support + 4 more |
| Content/Files | file_support, grade_support |
| Presentation/UI | page_support, output_support, html_writer_support, url_support, lang_support |
| Communication/Events | message_support, event_support, notification_support, calendar_support |
| Runtime/Infra | task_support, plugin_support, request_support, version_support, time_support, lock_support, check_support |
| Bridge | di_bridge_support, router_bridge_support |
Rule: Supports are @internal. Extensions consume them via facades in facade/moodle/, never by importing directly.
Adapters (ADR-301, ADR-302)¶
OO implementations of abstract contracts, injected via DI:
| Adapter | Contract | Purpose |
|---|---|---|
authentication |
authentication_interface |
Session and login |
capability |
capability_interface |
Permission checks |
authorizer |
authorizer_interface |
Composed auth + capability |
transaction_manager |
transaction_manager_interface |
DB transaction management |
logger |
Psr\Log\LoggerInterface |
PSR-3 logging |
translator |
translator_interface |
String localization |
view |
view_adapter_interface |
Moodle output rendering |
Typed Domain (ADR-204)¶
| Type | Count | Classification | Purpose |
|---|---|---|---|
| Entities | 17 | @api |
Hydrated Moodle objects (user, course, etc) |
| DTOs | 20 | Mixed | Data transfer (15 @api, 5 @internal) |
| Enums | 20 | @api |
Moodle constant wrappers (PHP 8.1 enums) |
| Contracts | 19 | @api |
Adapter + extension provider interfaces |
| Value Objects | 5 | @api |
Immutable concepts (capability, frankenstyle) |
Definitions (ADR-305)¶
Typed VOs that extensions declare to generate Moodle's db/*.php statics:
| Definition | Generates |
|---|---|
cache |
db/caches.php |
capability |
db/access.php |
service |
db/services.php ($functions) |
web_service |
db/services.php ($services) |
message |
db/messages.php |
hook |
db/hooks.php |
event_definition |
db/events.php + event classes |
file_area |
File area delegation |
check |
Health checks (runtime) |
Enforcement¶
The boundary is enforced at three levels:
| Tool | What it checks |
|---|---|
| Deptrac | Layer dependency graph — moodle/ depends only on shared/ |
| PHPStan | @internal import violations from extensions (ADR-904) |
| Rector | Automated migration rules |
Run checks: composer check:deptrac and composer check:stan.
Cross-references¶
- ADR-201 -- Boundary consolidation
- ADR-202 -- Internal organization by technical type
- ADR-203 -- Support layer pattern
- ADR-204 -- Entities and DTOs as
@api - ADR-205 -- Moodle API coverage registry
- Contracts -- Boundary contracts section
- Moodle Integration Patterns -- Authorizer, Privacy, Backup, Transaction