feat: add ConfigService and GlobalsRegistrar helpers#7
Conversation
There was a problem hiding this comment.
Pull request overview
Adds shared helpers for OpenCoreEMR modules to persist settings into the globals table and to register a module’s globals section (enable toggle + settings link) via the GlobalsInitializedEvent, along with unit tests and supporting test mocks.
Changes:
- Introduces
ConfigServicefor globals-table upserts, including an encrypted-save helper usingCryptoGen::encryptStandard(). - Introduces
GlobalsRegistrar+GlobalsSectionDescriptorto reduce module bootstrap boilerplate for globals-section registration. - Updates dependencies and adds PHPUnit tests + OpenEMR stubs/mocks for test execution.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ConfigService.php | Adds globals-table upsert helpers (plaintext + encrypted). |
| src/GlobalsRegistrar.php | Registers globals section, enable toggle, and settings-link via event listener. |
| src/GlobalsSectionDescriptor.php | Adds a descriptor object for globals registration parameters. |
| tests/Unit/ConfigServiceTest.php | Verifies upsert SQL + encryption behavior via mocked QueryUtils/CryptoGen. |
| tests/Unit/GlobalsRegistrarTest.php | Verifies globals metadata created by registration listener dispatch. |
| tests/Unit/GlobalsSectionDescriptorTest.php | Verifies descriptor property accessibility. |
| tests/Mocks/MockQueryUtils.php | Mocks OpenEMR QueryUtils for query capture/exception simulation. |
| tests/Mocks/MockCryptoGen.php | Mocks OpenEMR CryptoGen encryption for deterministic tests. |
| tests/Mocks/openemr_functions.php | Stubs OpenEMR global functions used by generated HTML. |
| tests/bootstrap.php | Loads mocks for tests. |
| composer.json | Adds symfony/event-dispatcher runtime dep and openemr/openemr dev dep + repositories. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4fec463 to
2fe2edd
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2fe2edd to
5253940
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Extract two patterns duplicated across every OCE module into this shared library: - ConfigService: upsert settings to the globals table via saveSetting() and saveEncryptedSetting() (CryptoGen). Uses portable ON DUPLICATE KEY UPDATE with bound parameters for MariaDB/MySQL compatibility. - GlobalsRegistrar + GlobalsSectionDescriptor: register a module's globals section (enable/disable toggle + settings page link) via GlobalsInitializedEvent, replacing identical boilerplate in every module bootstrap. Also adds openemr/openemr as a dev dependency (package repo pattern) and symfony/event-dispatcher as a runtime dependency. Closes #6 Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5253940 to
cecd310
Compare
Summary
saveSetting()andsaveEncryptedSetting()— upsert module settings to the OpenEMR globals table, with an encrypted variant using CryptoGenopenemr/openemras a dev dependency (package repo pattern) andsymfony/event-dispatcheras a runtime dependencyUsage
Closes #6
Test plan
🤖 Generated with Claude Code