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

Public Member Functions

 clearCache ()
 
 addSharedInstance ($instance, $className)
 
 removeSharedInstance ($className)
 
 getFactory ()
 
- Public Member Functions inherited from ObjectManager
 __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 setInstance (\Magento\Framework\ObjectManagerInterface $objectManager)
 
- Static Public Member Functions inherited from ObjectManager
static getInstance ()
 
static setInstance (\Magento\Framework\ObjectManagerInterface $objectManager)
 

Protected Attributes

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

Additional Inherited Members

- Static Protected Attributes inherited from ObjectManager
static $_instance
 

Detailed Description

ObjectManager for integration test framework.

Definition at line 11 of file ObjectManager.php.

Member Function Documentation

◆ addSharedInstance()

addSharedInstance (   $instance,
  $className 
)

Add shared instance.

Parameters
mixed$instance
string$className
Returns
void

Definition at line 90 of file ObjectManager.php.

91  {
92  $this->_sharedInstances[$className] = $instance;
93  }
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31

◆ clearCache()

clearCache ( )

Clear InstanceManager cache.

Returns
\Magento\TestFramework\ObjectManager

Definition at line 42 of file ObjectManager.php.

43  {
44  foreach ($this->_classesToDestruct as $className) {
45  if (isset($this->_sharedInstances[$className])) {
46  $this->_sharedInstances[$className] = null;
47  }
48  }
49 
50  \Magento\Framework\App\Config\Base::destroy();
51  $sharedInstances = [
52  \Magento\Framework\ObjectManagerInterface::class => $this,
53  \Magento\Framework\App\ObjectManager::class => $this,
54  ];
55  foreach ($this->persistedInstances as $persistedClass) {
56  if (isset($this->_sharedInstances[$persistedClass])) {
57  $sharedInstances[$persistedClass] = $this->_sharedInstances[$persistedClass];
58  }
59  }
60  $this->_sharedInstances = $sharedInstances;
61  $this->_config->clean();
62  $this->clearMappedTableNames();
63 
64  return $this;
65  }
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31

◆ getFactory()

getFactory ( )
Returns
\Magento\Framework\ObjectManager\FactoryInterface|\Magento\Framework\ObjectManager\Factory\Factory

Definition at line 120 of file ObjectManager.php.

◆ removeSharedInstance()

removeSharedInstance (   $className)

Remove shared instance.

Parameters
string$className
Returns
void

Definition at line 101 of file ObjectManager.php.

102  {
103  unset($this->_sharedInstances[$className]);
104  }
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31

◆ setInstance()

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

Set objectManager.

Parameters
\Magento\Framework\ObjectManagerInterface$objectManager
Returns
\Magento\Framework\ObjectManagerInterface

Definition at line 112 of file ObjectManager.php.

113  {
114  return self::$_instance = $objectManager;
115  }
$objectManager
Definition: bootstrap.php:17

Field Documentation

◆ $_classesToDestruct

$_classesToDestruct
protected
Initial value:
= [
\Magento\Framework\View\Layout::class,
\Magento\Framework\Registry::class
]

Definition at line 18 of file ObjectManager.php.

◆ $persistedInstances

$persistedInstances
protected
Initial value:
= [
\Magento\Framework\App\ResourceConnection::class,
\Magento\Framework\Config\Scope::class,
\Magento\Framework\ObjectManager\RelationsInterface::class,
\Magento\Framework\ObjectManager\ConfigInterface::class,
\Magento\Framework\Interception\DefinitionInterface::class,
\Magento\Framework\ObjectManager\DefinitionInterface::class,
\Magento\Framework\Session\Config::class,
\Magento\Framework\ObjectManager\Config\Mapper\Dom::class,
]

Definition at line 26 of file ObjectManager.php.


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