-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent ways of accessing the registry #890
Comments
Recommended way is to pass parameters to methods directly instead of using registry, but since registry is available the official way is №1. №2 is the result of automated tool that used part of namespace to generate unique variable name. This option is fine too because It's totally OK to name variables referencing same services differently in different clients. №3 is not recommended way because objectManager should not be referenced directly. I think this is the result of "quick" manual substitution of Mage::getSingleton |
Any argumentation? Is DI always preferred? When should the objectManager be used? |
Usage of objectManager as service locator leads to highly coupled code and hidden dependencies. Also ability to configure specific arguments for the client that uses OM directly is lost. Object manager can be used only in composition root of application (Bootstrap) and for unserialization of entities with service dependencies. |
Thank you anton that helped a lot! |
[SOUTH] Bugs: - MAGETWO-64643 Product Image Import - Incorrect Position - MAGETWO-64716 Product name ignores HTML tags and displays plain text - MAGETWO-59821 Gift card totals are not displaying correctly - MAGETWO-63200 State field is not required on checkout even though it is configured to be
During some review I've found three different ways of reading and writing to the registry:
Which one is the official way?
The text was updated successfully, but these errors were encountered: