Categories


Archives


Recent Posts


Categories


Magento 2: Dev 51 Changes the Object Manager Class

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

I looks like eBay threw another Magento 2 release over the wall into GitHub today. I’m going to start tagging entries here with a specific dev release tag as well as the generic magento2 tag.

First big change? The object manager we’ve been discussing is a different class. When you want to grab an instance of it, you can use

$object_manager = MagentoAppObjectManager::getInstance();    

It’s also worth mentioning that all versions of the object manager’s getInstance method come with the following PHPDoc warning.

 * TODO: Temporary solution for serialization, should be removed when Serialization problem is resolved
 *
 * @deprecated

This makes it sound like the ultimate plan is for client developers to use automatic dependency injection when/if they need an instance of the object manager. That’s going to make life tricky for developers converting extensions. By which I mean it’s going to make my life tricky.

This sort of change is also a good example of what the Magento 2 project is about right now. For many years, the Magento core team was forced into a situation where anything they released into the wild immediately had to be supported going forward. Magento 2’s long gestation cycle gives the developers breathing room to try new things, and evolve the development experience towards a better, more consistent path. I’ll be the first one on twitter with a “Magento 2 is Perl 6” joke, but in the past year we’ve seen real development resources allocated to the project. I don’t know what eBay’s plans are for Magento 2 in the future, but seeing what the developers are doing has peeled away a few layers of my cynicism about the project.

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 11th November 2013

email hidden; JavaScript is required