2

I always see objectmanager instantiated by objectmanagerinterface. But I never found di.xml that have preference of objectmanagerinterface to objectmanager.

Is it something I have never found? Or is objectmanager some special object that doesn't need di.xml?

1 Answer 1

1

Refer to this line from the object manager class:

https://github.com/magento/magento2/blob/2.3-develop/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php#L44

There is somewhere (not sure exactly where), but really early in the application a call to instantiate the Object manager class (not referred via interface), and when the OM gets instantiated it adds the mapping from the interface to itself.

1
  • Wow so objectmanager is actually a special object treated by object manager. Thanks! May 7, 2019 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.