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:
create($type, array $arguments = [])
: This creates a new object instance
get($type)
: This retrieves a cached object instance
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!!!