Dependency Injection migration: Service Provider and first migration#9108
Open
MissAllSunday wants to merge 6 commits intoSimpleMachines:release-3.0from
Open
Dependency Injection migration: Service Provider and first migration#9108MissAllSunday wants to merge 6 commits intoSimpleMachines:release-3.0from
MissAllSunday wants to merge 6 commits intoSimpleMachines:release-3.0from
Conversation
…p backward compatibility
Contributor
|
Examples of two different container implementations to demonstrate just how powerful this thing is. Both versions are fully working: |
Sesquipedalian
requested changes
Feb 13, 2026
Member
Sesquipedalian
left a comment
There was a problem hiding this comment.
In addition to fixing the noted minor nit, please run PHP-CS-Fixer on all modified and added files in order to make them compliant with the SMF code standard.
(It appears that our CI script that is supposed to run PHP-CS-Fixer as a linter is not working right now. If it were, this issue would have been flagged automatically.)
|
|
||
| // Initialize the container. | ||
| SMF\Container::init(); | ||
| \SMF\Infrastructure\Container::init(); |
Member
There was a problem hiding this comment.
Suggested change
| \SMF\Infrastructure\Container::init(); | |
| SMF\Infrastructure\Container::init(); |
nit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a way to register services as dependencies and migrates ErrorHandler to be served via the Container
Heres a Graph TB for reference on how ErrorHandler is been used and how backward compatibility is achieved by leaving the Original ErrorHandler as a Facade and mark it as deprecated in favor of the new Service. I'm aware original ErrorHandler has some duplicated code for calling the container, however, this is done to maximize backward compatibility.
graph TB subgraph "Legacy Code" A[Legacy Code Calls] A1["ErrorHandler::log()"] A2["ErrorHandler::fatal()"] A3["ErrorHandler::catch()"] A4["new ErrorHandler()"] end subgraph "Facade Layer" B[ErrorHandler Class] B1[getService Method] B2[Static Methods] end subgraph "DI Container" C[Container::getInstance] D[ServiceProvider] E[ServicesList.php] end subgraph "Service Layer" F[ErrorHandlerService] F1[handleError] F2[log] F3[fatal] F4[catch] end A --> B A1 --> B2 A2 --> B2 A3 --> B2 A4 --> B B --> B1 B2 --> B1 B1 -->|Try Container First| C C --> D D --> E E -->|Returns Shared Instance| F B1 -->|Fallback if Container Unavailable| F F --> F1 F --> F2 F --> F3 F --> F4 style B fill:#e1f5ff style F fill:#fff4e1 style C fill:#e8f5e9 style A fill:#fce4ecOf course arch and folders/naming convention should be subject to modifications to better suit current patterns if needed.