Skip to content

Submodules & Cross-Module Exports ​

When to split a module into submodules under Modules/, how Export/ acts as a strict public API boundary, and how to link cleanly across modules with return navigation (back).

Two submodule patterns ​

Submodules live under admin/Modules/<Parent>/Modules/<Submodule>/, share the exact same folder layout as a top-level module, and never have their own index.php. All submodule controllers are registered in the parent's index.php, and LimsRouter automatically discovers every submodule's Database/, access_config.php, and flag_config.php.

Pattern A: Embedded helper submodule (example: Notes/Modules/Todos) ​

Use this when a sub-feature lives inside one of the parent's pages (e.g. a checklist panel on a Note page):

  • Owns its own Database/Schemas/, Migrations/, Core/, and Controllers/TodosController.php (registered in Notes/index.php).
  • Exports an Angular component in Modules/Todos/Export/TodoPanel.component.ts that the parent page embeds directly.
  • Its controller answers the panel's actions with JsonResponse.

Pattern B: Multi-feature parent module (example: QualityAssurance) ​

Use this when one LIMS module hosts multiple full-page disciplines that share a dashboard, lookup services, and permissions (such as QualityAssurance hosting ProficiencyTesting, DocumentControl, Improvements, and CorrectiveActions):

  • Submodules own full Fusion pages in Modules/<Submodule>/UI/Views/<Page>/<Page>.component.ts. Fusion::render('MyPage/MyPage.component.ts', $props) resolves relative to the calling controller's nearest module or submodule UI/Views/ directory.
  • Shared parent Core/ & UI/Components/: Submodules inject shared parent services (for example, QualityUserService, QualityLookupService, BusinessDaysService, ReferenceNumberService, NotificationService) and shared UI helpers (postForm.ts, dates.ts).
  • Contract-based dashboard integration: The parent defines a small interface in Core/Interfaces/ (such as QualityFeature with url(), summary(), workItems()). Each submodule implements that interface inside its Export/ folder (Export/ImprovementsFeature.php), and the parent controller depends only on Export/ — never reaching into a submodule's Core/ or UI/.
  • Optional quick-action exports: A submodule can export a standalone Angular trigger + modal component (such as Export/LogImprovement.component.ts) that the parent dashboard and sibling registers embed cleanly via Export/.
  • Per-submodule permissions/flags: A submodule may rely on the parent's access_config.php, or add its own Modules/<Submodule>/access_config.php and flag_config.php when it needs an independent permission domain (like DocumentControl).

Quality Assurance module-specific conventions

Developers working specifically inside QualityAssurance can also consult the in-repo admin/Modules/QualityAssurance/DEVELOPING.md for QA's quality_features ID table, shared QA services, and legacy submodule migration notes.


Designing Export/ ​

Rule: Any code outside a module (another top-level module, a sibling submodule, or a parent module) may import only from Export/. Everything else (Core/, UI/, Database/) is private.

Put these in Export/:

  • Facade or contract implementations (Export/Sales.php, Export/OrdersFeature.php)
  • Embeddable Angular components (Export/OrderPanel.component.ts, Export/LogOrder.component.ts)
  • Legacy PHP HTML renderers if legacy pages need to embed your module (Export/RecordNotes.php)
  • Every DTO, value object, enum, or interface referenced by the public API — never force external callers to import from Core/Enums/ or Core/DTOs/.

When another module links into your module (for example, opening a Note from a Corrective Action page), carry the calling page's address in a ?back= query parameter:

  1. Build the link in Export/: Have your Export/ helper populate back automatically so callers don't repeat URL construction.
  2. Validate back on the server: Accept only relative paths inside the same application (never external URLs or javascript: URIs — see Notes/UI/Components/BackLink.php).
  3. Preserve back across edits: Pass the validated back prop to your Angular views and append back: this.back() to every url(...) call (url() omits null/undefined automatically).
  4. Leave via a full page load: Because the calling page belongs to a different module, render the Back button as a plain <a [href]="back"> or set window.location.href = back — never call navigate(back).

Labmin LIMS Module Developer Documentation