2

I am looking at the concept of the object manager, but I didn't get any proper explanation about that. I also have gone through the below link, but they are just explaining the usage, etc..

https://devdocs.magento.com/guides/v2.3/extension-dev-guide/object-manager.html

But I want to know what is the object manager in magento2. Thanks in advance for your better support

asked Sep 6, 2019 at 4:37

1 Answer 1

6

The initializing of objects in Magento is done via what is called the object manager.

The object manager itself is an instance of the Magento\Framework\ObjectManager\ObjectManager class that implements the Magento\Framework\ObjectManagerInterface class. The ObjectManager class defines the following three methods:

  1. create($type, array $arguments = []): This creates a new object instance

  2. get($type): This retrieves a cached object instance

  3. configure(array $configuration): This configures the di instance

The object manager can instantiate a PHP class, which can be a model, helper, or block object. Unless the class that we are working with has already received an instance of the object manager, we can receive it by passing ObjectManagerInterface into the class constructor, as follows:

public function __construct(
 \Magento\Framework\ObjectManagerInterface $objectManager
)
{
 $this->_objectManager = $objectManager;
}

Get detailed information from https://www.vortexcommerce.com/magento-2-object-manager/

Hope it helps!!!

answered Sep 6, 2019 at 4:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.