Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Data Structures | Public Member Functions | Static Public Member Functions | Static Protected Attributes
ObjectManager Class Reference
Inheritance diagram for ObjectManager:
ObjectManager ObjectManagerInterface ObjectManager

Data Structures

class  ConfigLoaderTest
 

Public Member Functions

 __construct (FactoryInterface $factory, \Magento\Framework\ObjectManager\ConfigInterface $config, array &$sharedInstances=[])
 
- Public Member Functions inherited from ObjectManager
 __construct (FactoryInterface $factory, ConfigInterface $config, &$sharedInstances=[])
 
 create ($type, array $arguments=[])
 
 get ($type)
 
 configure (array $configuration)
 

Static Public Member Functions

static getInstance ()
 
static setInstance (\Magento\Framework\ObjectManagerInterface $objectManager)
 

Static Protected Attributes

static $_instance
 

Additional Inherited Members

- Protected Attributes inherited from ObjectManager
 $_factory
 
 $_sharedInstances = []
 
 $_config
 

Detailed Description

Direct usage of this class is strictly discouraged.

Wrapper around object manager with workarounds to access it in client code. Provides static access to objectManager, that is required for unserialization of objects.

@api @SuppressWarnings(PHPMD.CouplingBetweenObjects)

Since
100.0.2

Definition at line 20 of file ObjectManager.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( FactoryInterface  $factory,
\Magento\Framework\ObjectManager\ConfigInterface  $config,
array &  $sharedInstances = [] 
)
Parameters
FactoryInterface$factory
\Magento\Framework\ObjectManager\ConfigInterface$config
array$sharedInstances

Definition at line 58 of file ObjectManager.php.

62  {
63  parent::__construct($factory, $config, $sharedInstances);
64  self::$_instance = $this;
65  }
$config
Definition: fraud_order.php:17

Member Function Documentation

◆ getInstance()

static getInstance ( )
static

Retrieve object manager

Returns
ObjectManager
Exceptions

Definition at line 33 of file ObjectManager.php.

34  {
35  if (!self::$_instance instanceof \Magento\Framework\ObjectManagerInterface) {
36  throw new \RuntimeException('ObjectManager isn\'t initialized');
37  }
38  return self::$_instance;
39  }

◆ setInstance()

static setInstance ( \Magento\Framework\ObjectManagerInterface  $objectManager)
static

Set object manager instance

Parameters
\Magento\Framework\ObjectManagerInterface$objectManager
Exceptions

Definition at line 48 of file ObjectManager.php.

49  {
50  self::$_instance = $objectManager;
51  }
$objectManager
Definition: bootstrap.php:17

Field Documentation

◆ $_instance

$_instance
staticprotected

Definition at line 25 of file ObjectManager.php.


The documentation for this class was generated from the following file: