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

Public Member Functions

 restore (ObjectManager $objectManager, $directoryList, array $arguments)
 
- Public Member Functions inherited from ObjectManagerFactory
 __construct (DirectoryList $directoryList, DriverPool $driverPool, ConfigFilePool $configFilePool)
 

Protected Member Functions

 _loadPrimaryConfig (DirectoryList $directoryList, $driverPool, $argumentMapper, $appMode)
 
- Protected Member Functions inherited from ObjectManagerFactory
 createDeploymentConfig (DirectoryList $directoryList, ConfigFilePool $configFilePool, array $arguments)
 
 createArgumentInterpreter (\Magento\Framework\Stdlib\BooleanUtils $booleanUtils)
 
 _loadPrimaryConfig (DirectoryList $directoryList, $driverPool, $argumentMapper, $appMode)
 
 _createPluginList (\Magento\Framework\ObjectManagerInterface $objectManager, \Magento\Framework\ObjectManager\RelationsInterface $relations, \Magento\Framework\ObjectManager\DefinitionFactory $definitionFactory, \Magento\Framework\ObjectManager\Config\Config $diConfig, \Magento\Framework\ObjectManager\DefinitionInterface $definitions)
 

Protected Attributes

 $_locatorClassName = \Magento\TestFramework\ObjectManager::class
 
 $_configClassName = \Magento\TestFramework\ObjectManager\Config::class
 
 $envFactoryClassName = \Magento\TestFramework\App\EnvironmentFactory::class
 
 $_primaryConfigData = null
 
- Protected Attributes inherited from ObjectManagerFactory
 $_locatorClassName = \Magento\Framework\App\ObjectManager::class
 
 $_configClassName = \Magento\Framework\Interception\ObjectManager\ConfigInterface::class
 
 $envFactoryClassName = \Magento\Framework\App\EnvironmentFactory::class
 
 $directoryList
 
 $driverPool
 
 $configFilePool
 
 $factory
 

Additional Inherited Members

- Data Fields inherited from ObjectManagerFactory
const INIT_PARAM_DEPLOYMENT_CONFIG_FILE = 'MAGE_CONFIG_FILE'
 
const INIT_PARAM_DEPLOYMENT_CONFIG = 'MAGE_CONFIG'
 

Detailed Description

Class ObjectManagerFactory

@SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 17 of file ObjectManagerFactory.php.

Member Function Documentation

◆ _loadPrimaryConfig()

_loadPrimaryConfig ( DirectoryList  $directoryList,
  $driverPool,
  $argumentMapper,
  $appMode 
)
protected

Load primary config

Parameters
\Magento\Framework\App\Filesystem\DirectoryList$directoryList
DriverPool$driverPool
mixed$argumentMapper
string$appMode
Returns
array

Definition at line 82 of file ObjectManagerFactory.php.

83  {
84  if (null === $this->_primaryConfigData) {
85  $this->_primaryConfigData = array_replace(
86  parent::_loadPrimaryConfig($directoryList, $driverPool, $argumentMapper, $appMode),
87  [
88  'default_setup' => ['type' => \Magento\TestFramework\Db\ConnectionAdapter::class]
89  ]
90  );
91  $diPreferences = [];
92  $diPreferencesPath = __DIR__ . '/../../../etc/di/preferences/';
93 
94  $preferenceFiles = glob($diPreferencesPath . '*.php');
95 
96  foreach ($preferenceFiles as $file) {
97  if (!is_readable($file)) {
98  throw new LocalizedException(__("'%1' is not readable file.", $file));
99  }
100  $diPreferences = array_replace($diPreferences, include $file);
101  }
102 
103  $this->_primaryConfigData['preferences'] = array_replace(
104  $this->_primaryConfigData['preferences'],
105  $diPreferences
106  );
107  }
109  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
__()
Definition: __.php:13

◆ restore()

restore ( ObjectManager  $objectManager,
  $directoryList,
array  $arguments 
)

Restore locator instance

Parameters
ObjectManager$objectManager
DirectoryList$directoryList
array$arguments
Returns
ObjectManager

Definition at line 51 of file ObjectManagerFactory.php.

52  {
54  $this->directoryList = $directoryList;
55  $objectManager->configure($this->_primaryConfigData);
56  $objectManager->addSharedInstance($this->directoryList, \Magento\Framework\App\Filesystem\DirectoryList::class);
57  $objectManager->addSharedInstance($this->directoryList, \Magento\Framework\Filesystem\DirectoryList::class);
58  $deploymentConfig = $this->createDeploymentConfig($directoryList, $this->configFilePool, $arguments);
59  $this->factory->setArguments($arguments);
60  $objectManager->addSharedInstance($deploymentConfig, \Magento\Framework\App\DeploymentConfig::class);
61  $objectManager->addSharedInstance(
62  $objectManager->get(\Magento\Framework\App\ObjectManager\ConfigLoader::class),
63  \Magento\Framework\ObjectManager\ConfigLoaderInterface::class
64  );
65  $objectManager->get(\Magento\Framework\Interception\PluginListInterface::class)->reset();
66  $objectManager->configure(
67  $objectManager->get(\Magento\Framework\App\ObjectManager\ConfigLoader::class)->load('global')
68  );
69 
70  return $objectManager;
71  }
$objectManager
Definition: bootstrap.php:17
static setInstance(\Magento\Framework\ObjectManagerInterface $objectManager)
$deploymentConfig
$arguments
createDeploymentConfig(DirectoryList $directoryList, ConfigFilePool $configFilePool, array $arguments)

Field Documentation

◆ $_configClassName

$_configClassName = \Magento\TestFramework\ObjectManager\Config::class
protected

Definition at line 31 of file ObjectManagerFactory.php.

◆ $_locatorClassName

$_locatorClassName = \Magento\TestFramework\ObjectManager::class
protected

Definition at line 24 of file ObjectManagerFactory.php.

◆ $_primaryConfigData

$_primaryConfigData = null
protected

Definition at line 41 of file ObjectManagerFactory.php.

◆ $envFactoryClassName

$envFactoryClassName = \Magento\TestFramework\App\EnvironmentFactory::class
protected

Definition at line 36 of file ObjectManagerFactory.php.


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