In Magento 1 there were three “types” of classes which you could instantiate via Magento’s various object factories: Models, Blocks, and Helpers
Mage::getModel('group/class'); Mage::helper('group/class'); Mage::getSingleton('core/layout')->createBlock('group/class');
In Magento 2, all classes are available to the object manager. **This includes classes in
lib*. Consider the
Dir object we mentioned in the last post.
$object_manager = MagentoCoreModelObjectManager::getInstance(); $dir = $object_manager->get('MagentoAppDir');
This object comes from a file in Magento’s
In Magento 1 library classes were directly instantiated via PHP. The above would have looked something like this
$dir = new Magento_App_Dir;
The consequences of this? We should be able to rewrite classes in the
lib folder without relying on a code-pool override. Which is good, because there are no code-pool overrides in Magento 2.