Replace hard coded "new Varien_Image" with "Mage::getModel('core/image')" #2114
Replies: 3 comments
-
Does getModel work with non module classes as in
Also are there any other possible cases we should think about? out of curiosity, what is the usecase you need for changing this models? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I investigated the getModel resolution quite intensive a few years back. Internally the Module/Classname is just a reference and normally you can also use full class names. If the rewrite would not work with them, we could introduce a pseudo class, which does not exist, but using a rewrite to point to the Varien_Image, as the rewrite logic uses full class names. Would it be also enough, if just the Image Adapter would be properly configurable? We also have already plans to introduce support for DI(there was a working solution for M1 someone already had) but thats more far away. Doing the change for Varien_Io_File seems harder, because of the big number of uses in different contexts. |
Beta Was this translation helpful? Give feedback.
-
I want to suggest replacing the hard coded "new Varien_Image" with "Mage::getModel('core/image')", so loading of these models can be done the Magento way.
Never understood why Magento didn't do this to begin with.
This way, other modules can rewrite these models and do some new things.
We are already doing this is our projects and have implemented cloud file storage this way. Currently using patches to make the core edits. Yeah :(
The new class Mage_Core_Model_Image just extends the old, so nothing would break.
Like this, other models like Varien_Io_File and Varien_Image_Upload would also be replaced the same way.
If the community agrees, I'll build it.
Beta Was this translation helpful? Give feedback.
All reactions